[PATCH] D132225: [Assignment Tracking][6/*] Add trackAssignments function

Orlando Cazalet-Hyams via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 19 06:14:55 PDT 2022


Orlando created this revision.
Orlando added a project: debug-info.
Herald added subscribers: nlopes, hiraditya.
Herald added a project: All.
Orlando requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The Assignment Tracking debug-info feature is outlined in this RFC <https://discourse.llvm.org/t/rfc-assignment-tracking-a-better-way-of-specifying-variable-locations-in-ir/62367>. 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 `trackAssignments` which adds assignment tracking metadata to a function for a specified set of variables. The intended callers are the inliner and the front end - those calls will be added in separate patches.

I've added a pass called `declare-to-assign` (`AssignmentTrackingPass`) that converts `dbg.declare` intrinsics to `dbg.assign`s using `trackAssignments` so that the function can be easily tested (see llvm/test/DebugInfo/Generic/track-assignments.ll). The pass could also be used by front ends to easily test out enabling assignment tracking.

There is still at least one TODO: `trackAssignments` (and the rest of the pipeline) currently only works for local variables backed by an alloca. Some local variables have their storage allocated by the calling function with the address passed in with a sret or byval parameter. I have a solution in mind for this but would like to tackle that after the core of the feature is accepted.


https://reviews.llvm.org/D132225

Files:
  llvm/include/llvm/IR/DIBuilder.h
  llvm/include/llvm/IR/DebugInfo.h
  llvm/include/llvm/IR/Value.h
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfo.cpp
  llvm/lib/IR/Value.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/test/DebugInfo/Generic/assignment-tracking/track-assignments.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132225.453965.patch
Type: text/x-patch
Size: 50209 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220819/e2ba0a8a/attachment.bin>


More information about the llvm-commits mailing list