This PR instruments the optimization passes in the SystemZ backend with calls to `MachineFunction::substituteDebugValuesForInst` where instruction substitutions are made to instructions that may compute tracked values. Tests are also added for each of the substitutions that were inserted. Details on the individual passes follow. ### systemz-copy-physregs When a copy targets an access register, we redirect the copy via an auxiliary register. This leads to the final result being written by a newly inserted SAR instruction, rather than the original MI, so we need to update the debug value tracking to account for this. ### systemz-long-branch This pass relaxes relative branch instructions based on the actual locations of blocks. Only one of the branch instructions qualifies for debug value tracking: BRCT, i.e. branch-relative-on-count, which subtracts 1 from a register and branches if the result is not zero. This is relaxed into an add-immediate and a conditional branch, so any `debug-instr-number` present must move to the add-immediate instruction. ### systemz-post-rewrite This pass replaces `LOCRMux` and `SELRMux` pseudoinstructions with either the real versions of those instructions, or with branching programs that implement the intent of the Pseudo. In all these cases, any `debug-instr-number` attached to the pseudo needs to be reallocated to the appropriate instruction in the result, either LOCR, SELR, or a COPY. ### systemz-elim-compare Similar to systemz-long-branch, for this pass, only few substitutions are necessary, since it mainly deals with conditional branch instructions. The only exceptiona are again branch-relative-on-count, as it modifies a counter as part of the instruction, as well as any of the load instructions that are affected.
66 lines
2.3 KiB
YAML
66 lines
2.3 KiB
YAML
# Check that the backend properly tracks debug-instr-references across the
|
|
# elim-compare pass.
|
|
#
|
|
# RUN: llc %s -mtriple=s390x-linux-gnu -mcpu=z14 -run-pass=systemz-elim-compare \
|
|
# RUN: -o - 2>&1 | FileCheck %s
|
|
|
|
# bb.0 - elimination of CHI, modification of BRC, no substitutions
|
|
# bb.1 - elimination of CHI, replacement of LR with LTR, one substitution
|
|
# bb.2 - elimination of L and CHI, modification of CondTrap into LAT, one substitution
|
|
# CHECK: name: foo
|
|
# CHECK: debugValueSubstitutions:
|
|
# these are the correct substitutions
|
|
# CHECK-NEXT: - { srcinst: 5, srcop: 0, dstinst: 13, dstop: 0, subreg: 0 }
|
|
# CHECK-NEXT: - { srcinst: 7, srcop: 0, dstinst: 9, dstop: 0, subreg: 0 }
|
|
# CHECK-NEXT: - { srcinst: 10, srcop: 0, dstinst: 14, dstop: 0, subreg: 0 }
|
|
# we also need to make sure that these are the only substitutions
|
|
# CHECK-NEXT: constants: []
|
|
---
|
|
name: foo
|
|
tracksRegLiveness: true
|
|
liveins:
|
|
- { reg: '$r2l', virtual-reg: '' }
|
|
- { reg: '$r3l', virtual-reg: '' }
|
|
- { reg: '$r4l', virtual-reg: '' }
|
|
- { reg: '$r5d', virtual-reg: '' }
|
|
debugValueSubstitutions: []
|
|
body: |
|
|
bb.0:
|
|
successors: %bb.1(0x80000000)
|
|
liveins: $r2l, $r3l, $r4l, $r5d
|
|
|
|
renamable $r3l = nsw AR killed renamable $r3l, renamable $r2l, implicit-def dead $cc, debug-instr-number 1
|
|
CHI renamable $r3l, 0, implicit-def $cc, debug-instr-number 2
|
|
BRC 14, 12, %bb.1, implicit $cc, debug-instr-number 3
|
|
|
|
bb.1:
|
|
successors: %bb.2(0x80000000)
|
|
liveins: $r2l, $r3l, $r4l, $r5d
|
|
|
|
CHI renamable $r2l, 0, implicit-def $cc, debug-instr-number 4
|
|
renamable $r3l = LR renamable $r2l, debug-instr-number 5
|
|
BRC 14, 8, %bb.2, implicit killed $cc, debug-instr-number 6
|
|
|
|
bb.2:
|
|
successors: %bb.3(0x80000000)
|
|
liveins: $r2l, $r3l, $r4l, $r5d
|
|
|
|
renamable $r2l = L killed renamable $r5d, 0, $noreg, debug-instr-number 7
|
|
CHI renamable $r2l, 0, implicit-def $cc, debug-instr-number 8
|
|
CondTrap 14, 8, implicit killed $cc, debug-instr-number 9
|
|
J %bb.3
|
|
|
|
bb.3:
|
|
successors: %bb.4(080000000)
|
|
liveins: $r2l, $r3l, $r4l, $r5d
|
|
|
|
renamable $r3l = L renamable $r5d, 0, $noreg, debug-instr-number 10
|
|
CHI renamable $r3l, 0, implicit-def $cc, debug-instr-number 11
|
|
BRC 14, 8, %bb.4, implicit killed $cc, debug-instr-number 12
|
|
|
|
bb.4:
|
|
$r2l = LHI 2
|
|
Return implicit $r2l
|
|
|
|
...
|