[Assignment Tracking][21/*] Account for assignment tracking in inliner
authorOCHyams <orlando.hyams@sony.com>
Fri, 18 Nov 2022 11:49:43 +0000 (11:49 +0000)
committerOCHyams <orlando.hyams@sony.com>
Fri, 18 Nov 2022 11:55:05 +0000 (11:55 +0000)
commite3cd498ff7748f967be1bdcc0a994e40ce82268f
treeead137f181964596c4d85a97f4fb7e8d34575b8a
parent63f79fe2eb89a891f96a3893df6aaf5153848b54
[Assignment Tracking][21/*] Account for assignment tracking in inliner

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

The inliner requires two additions:

fixupAssignments - Update inlined instructions' DIAssignID metadata so that
inlined DIAssignID attachments are unique to the inlined instance.

trackInlinedStores - Treat inlined stores to caller-local variables
(i.e. callee stores to argument pointers that point to the caller's allocas) as
assignments. Track them using trackAssignments, which is the same method as is
used by the AssignmentTrackingPass. This means that we're able to detect stale
memory locations due to DSE after inlining. Because the stores are only tracked
_after_ inlining, any DSE or movement of stores _before_ inlining will not be
accounted for. This is an accepted limitation mentioned in the RFC.

One change is also required:

Update CloneBlock to preserve debug use-before-defs. Otherwise the assignments
will be dropped due to having the intrinsic operands replaced with empty
metadata (see use-before-def.ll in this patch and this related discourse post.

Reviewed By: jmorse

Differential Revision: https://reviews.llvm.org/D133318
llvm/lib/Transforms/Utils/CloneFunction.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp
llvm/test/DebugInfo/Generic/assignment-tracking/inline/id.ll [new file with mode: 0644]
llvm/test/DebugInfo/Generic/assignment-tracking/inline/inline-stores.ll [new file with mode: 0644]
llvm/test/DebugInfo/Generic/assignment-tracking/inline/use-before-def.ll [new file with mode: 0644]