This is an archive of the discontinued LLVM Phabricator instance.

[Assignment Tracking][7/*] Add assignment tracking functionality to clang
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.


This patch plumbs the AssignmentTrackingPass (AKA declare-to-assign), added in the previous patch in this set, into the optimisation pipeline from clang. clang/test/CodeGen/assignment-tracking/assignment-tracking.cpp is the main test for this patch.

Note: while clang (with the help of the declare-to-assign pass) can now emit Assignment Tracking metadata, the llvm middle and back ends don't yet understand it.

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: ormris. · View Herald Transcript
Orlando updated this revision to Diff 454437.Aug 22 2022, 3:13 AM
jmorse added a subscriber: jmorse.Sep 6 2022, 9:36 AM

This looks good -- however the last two tests running "opt" are probably running too much of LLVM to put into clang. Do these parts really need to be tested from the frontend, or can they be put in llvm?

This returns us to that perennial topic, end-to-end and cross-project tests, which I think for now we'll need to defer as "let's not think about that".

clang/test/CodeGen/assignment-tracking/assignment-tracking.cpp
1–2

Small risk that this is running "too much" of LLVM, and spurious changes will cause clang tests to fail. To me, it feels alright though.

I suspect that if it's in the clang CodeGen dir, then you should be using %clang_cc1 or whatever the macro is, and the cc1 command line to run this test. Same with the other tests.

This looks good -- however the last two tests running "opt" are probably running too much of LLVM to put into clang. Do these parts really need to be tested from the frontend, or can they be put in llvm?

I could remove the opt call and keep the tests there? The tests would function as intended still. The verify check just felt like a free win to me, but I hadn't considered the layering of the tools.

This returns us to that perennial topic, end-to-end and cross-project tests, which I think for now we'll need to defer as "let's not think about that".

SGTM

clang/test/CodeGen/assignment-tracking/assignment-tracking.cpp
1–2

My thinking was that source code tests add extra comfort and surface area to catch problems if (/when) we change "how dbg.assign / DIAssignID are generated".

I suspect that if it's in the clang CodeGen dir, then you should be using %clang_cc1 or whatever the macro i

SGTM, will do.

jmorse requested changes to this revision.Sep 13 2022, 9:44 AM

(Hitting the big red button to return this to your "revision" queue).

This revision now requires changes to proceed.Sep 13 2022, 9:44 AM
Orlando updated this revision to Diff 460023.Sep 14 2022, 3:39 AM
Orlando marked an inline comment as done.

+ use %clang_cc1 substitution in tests (and add test assignment-tracking-opts.c which uses %clang)

jmorse accepted this revision.Sep 14 2022, 7:27 AM

Hmmmm. I think -O0 is also running a reasonable amount of llvm. On the other hand, if it turns out to be a noisy test then we can come back to it at a later date -- we've done our best to ensure there's a small surface that can change, and the check lines are mostly for metadata rather than anything else. LGTM

This revision is now accepted and ready to land.Sep 14 2022, 7:27 AM
This revision was landed with ongoing or failed builds.Nov 8 2022, 9:49 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptNov 8 2022, 9:49 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript