This is an archive of the discontinued LLVM Phabricator instance.

[Assignment Tracking][2/*] Add flags to enable Assignment Tracking
ClosedPublic

Authored by Orlando on Aug 19 2022, 6:14 AM.

Details

Summary

The Assignment Tracking debug-info feature is outlined in this RFC. This first series of patches adds documentation, the changes necessary to start emitting and using the new metadata, and updates clang with an option to enable the feature. Working with the new metadata in the middle and back end will come later. There are still a few rough edges but I'm putting these patches up now hoping to get feedback on the design and implementation from the upstream community.


Add flags to enable Assignment Tracking:

Enable in clang: -Xclang -fexperimental-assignment-tracking

Enable in llvm tools: -experimental-assignment-tracking

When assignment tracking is enabled in clang it will pass on the flag to enable the feature in lllvm. It's undefined behaviour to read IR that contains assignment tracking primitives without specifying the feature flags.

Tests will come with later patches that add assignment tracking features.

Diff Detail

Event Timeline

Orlando created this revision.Aug 19 2022, 6:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 19 2022, 6:14 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
Orlando requested review of this revision.Aug 19 2022, 6:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 19 2022, 6:14 AM
Orlando updated this revision to Diff 456658.Aug 30 2022, 7:10 AM

+ Add context to diff

jmorse added a subscriber: jmorse.Aug 30 2022, 7:22 AM

I get the feeling that this is creating two places to store the flag rather than one -- there's the EnableAssignmentTracking flag which ends up in TargetOptions I think(?), I believe MarshallingInfoFlag<CodeGenOpts<"EnableAssignmentTracking">>; causes the Xclang flag to be stored there. Then there's the cl::opt flag which is controlled by the same. This raises the future possibility that one could be on, but the other off -- I suspect you'll need to pick one and stick with it.

NB: I've gone off putting things in TargetOptions after finding that they're hard to control (i.e.: impossible) during LTO:

https://lists.llvm.org/pipermail/llvm-dev/2020-December/147090.html

Because the arguments are parsed after TargetOptions is created.

clang/include/clang/Basic/CodeGenOptions.def
320

This wants a docu-comment, as in the surrounding flags.

I get the feeling that this is creating two places to store the flag rather than one -- there's the EnableAssignmentTracking flag which ends up in TargetOptions I think(?), I believe MarshallingInfoFlag<CodeGenOpts<"EnableAssignmentTracking">>; causes the Xclang flag to be stored there.

I thought that it was putting it in CodeGenOptions, meaning we can check the value of the flag here in Clang - used in D132226 (the if condition).

I'm not trying to push back on any suggested changes, I am just slightly lost on this side of LLVM. It could well be that storing in CodeGenOptions is undesirable too, but I thought it was worth checking.

jmorse accepted this revision.Sep 13 2022, 9:21 AM

I get the feeling that this is creating two places to store the flag rather than one -- there's the EnableAssignmentTracking flag which ends up in TargetOptions I think(?), I believe MarshallingInfoFlag<CodeGenOpts<"EnableAssignmentTracking">>; causes the Xclang flag to be stored there.

I thought that it was putting it in CodeGenOptions, meaning we can check the value of the flag here in Clang - used in D132226 (the if condition).

Uuuuuuuhhhh. Yeah you're right, that makes sense. Carry on. LGTM, wants the comment nit fixing though.

I'm not trying to push back on any suggested changes, I am just slightly lost on this side of LLVM. It could well be that storing in CodeGenOptions is undesirable too, but I thought it was worth checking.

This revision is now accepted and ready to land.Sep 13 2022, 9:21 AM
This revision was landed with ongoing or failed builds.Nov 2 2022, 10:07 AM
This revision was automatically updated to reflect the committed changes.
Orlando marked an inline comment as done.
Herald added a project: Restricted Project. · View Herald TranscriptNov 2 2022, 10:07 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript