aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/ProgramStackTest.cpp
diff options
context:
space:
mode:
authorShubham Sandeep Rastogi <srastogi22@apple.com>2025-04-30 14:17:22 -0700
committerGitHub <noreply@github.com>2025-04-30 14:17:22 -0700
commit9b8c96a040ae6b76bb73690acfc5bea85aaa51d4 (patch)
tree3c273c7d8bd93499a02c19f3c69c4067368a9e31 /llvm/unittests/Support/ProgramStackTest.cpp
parent02e316cf8c9c73aad580e8c0d1b3b691567601ca (diff)
downloadllvm-9b8c96a040ae6b76bb73690acfc5bea85aaa51d4.zip
llvm-9b8c96a040ae6b76bb73690acfc5bea85aaa51d4.tar.gz
llvm-9b8c96a040ae6b76bb73690acfc5bea85aaa51d4.tar.bz2
[InstrRef] Preserve debug instr num in aarch64-ldst-opt. (#136009)
The aarch64-ldst-opt pass tries to merge two load instructions (LDR*) to a load pair instruction (LDP*). When merging the instructions, there is a case where one of the loads would have to also be sign extended. In either case, (sign extend or not), the pass needs to preserve the debug-instr-number from the original loads to the load pair instruction to make sure debug info isn't lost in the case where instruction referencing is being used. For example: We can have something like this: ``` debugValueSubstitutions:[] $x1 = LDRXui $x0, 1, debug-instr-number 1 DBG_INSTR_REF !13, dbg-instr-ref(1, 0), debug-location !11 $x0 = LDRXui killed $x0, 0, debug-instr-number 2 DBG_INSTR_REF !14, dbg-instr-ref(2, 0), debug-location !11 ``` This would be changed to: ``` debugValueSubstitutions: [] $x0, $x1 = LDPXi $x0, 0 DBG_INSTR_REF !12, dbg-instr-ref(1, 0), debug-location !14 DBG_INSTR_REF !13, dbg-instr-ref(2, 0), debug-location !14 ``` In this case, we need to create a new debug instruction number for the `LDP` instruction, we then need to add entries into the debugSubstitutions table to map the old instr-refs to the new ones. After this patch, the result will be: ``` debugValueSubstitutions: - { srcinst: 1, srcop: 0, dstinst: 3, dstop: 1, subreg: 0 } - { srcinst: 2, srcop: 0, dstinst: 3, dstop: 0, subreg: 0 } $x0, $x1 = LDPXi $x0, 0, debug-instr-number 3 DBG_INSTR_REF !12, dbg-instr-ref(1, 0), debug-location !14 DBG_INSTR_REF !12, dbg-instr-ref(2, 0), debug-location !14 ``` However, this is not all, we also can have a case where there is a sign-extend involved, let's look at the case: ``` debugValueSubstitutions:[] $w1 = LDRWui $x0, 1, debug-instr-number 1 DBG_INSTR_REF !7, dbg-instr-ref(1, 0), debug-location !9 $x0 = LDRSWui $x0, 0, debug-instr-number 2 DBG_INSTR_REF !8, dbg-instr-ref(2, 0), debug-location !9 ``` This will become: ``` debugValueSubstitutions:[] $w0, $w1 = LDPWi $x0, 0 $w0 = KILL $w0, implicit-def $x0 $x0 = SBFMXri $x0, 0, 31 DBG_INSTR_REF !7, dbg-instr-ref(1, 0), debug-location !9 DBG_INSTR_REF !8, dbg-instr-ref(2, 0), debug-location !9 ``` $x0 is where the final value is stored, so the sign extend (SBFMXri) instruction contains the final value we care about we give it a new debug-instr-number 3. Whereas, $w1 contains the final value that we care about, therefore the LDP instruction is also given a new debug-instr-number 4. We have to add these subsitutions to the debugValueSubstitutions table. However, we also have to ensure that the OpIndex that pointed to debug-instr-number 1 gets updated to 1, because $w1 is the second operand of the LDP instruction. The result after the patch looks like: ``` debugValueSubstitutions: - { srcinst: 1, srcop: 0, dstinst: 4, dstop: 1, subreg: 0 } - { srcinst: 2, srcop: 0, dstinst: 3, dstop: 0, subreg: 0 } $w0, $w1 = LDPWi $x0, 0, debug-instr-number 4 $w0 = KILL $w0, implicit-def $x0 $x0 = SBFMXri $x0, 0, 31, debug-instr-number 3 DBG_INSTR_REF !7, dbg-instr-ref(1, 0), debug-location !9 DBG_INSTR_REF !8, dbg-instr-ref(2, 0), debug-location !9 ``` This patch addresses that problem.
Diffstat (limited to 'llvm/unittests/Support/ProgramStackTest.cpp')
0 files changed, 0 insertions, 0 deletions