[Assignment Tracking][4/*] Add llvm.dbg.assign intrinsic boilerplate
authorOCHyams <orlando.hyams@sony.com>
Mon, 7 Nov 2022 09:31:45 +0000 (09:31 +0000)
committerOCHyams <orlando.hyams@sony.com>
Mon, 7 Nov 2022 10:09:22 +0000 (10:09 +0000)
commitc37f29c49ea237eaf65dd137bffc1f3316f82951
tree3e017e86e6a46b5f84ed5aab358b32de6bf07397
parentb46427b9a2fa2587e9087ab7e2bbb2c5abbb30e3
[Assignment Tracking][4/*] Add llvm.dbg.assign intrinsic boilerplate

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

Add the llvm.dbg.assign intrinsic boilerplate. This updates the textual-bitcode
roundtrip test to also check that round-tripping with the intrinsic works.

The intrinsic marks the position of a source level assignment.

The llvm.dbg.assign interface looks like this (each parameter is wrapped in
MetadataAsValue, and Value * type parameters are first wrapped in
ValueAsMetadata):

    void @llvm.dbg.assign(Value *Value,
                          DIExpression *ValueExpression,
                          DILocalVariable *Variable,
                          DIAssignID *ID,
                          Value *Address,
                          DIExpression *AddressExpression)

The first three parameters look and behave like an llvm.dbg.value. ID is a
reference to a store. The intrinsic is "linked to" instructions in the same
function that use the same ID as an attachment. That is mostly conceptual at
this point; the two-way link infrastructure will come in another patch. Address
is the destination address of the store and it is modified by
AddressExpression. LLVM currently encodes variable fragment information in
DIExpressions, so as an implementation quirk the FragmentInfo for Variable is
contained within ValueExpression only.

Reviewed By: jmorse

Differential Revision: https://reviews.llvm.org/D132223
llvm/include/llvm/IR/IntrinsicInst.h
llvm/include/llvm/IR/Intrinsics.td
llvm/lib/IR/IntrinsicInst.cpp
llvm/lib/IR/Verifier.cpp
llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/roundtrip.ll
llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/verify.ll [new file with mode: 0644]