| Issue |
244896
|
| Summary |
[AArch64][SME] Debug info changes code after a conditional smstart (expandConditionalPseudo splits off a debug-only block)
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
yqtian-se
|
With `-g`, the code for a streaming-compatible function differs from `-g0`: the `tbz` that skips
the conditional `smstart` targets an extra `b` instead of the join block.
```c
int g(void);
int f(int c, int d) __arm_streaming_compatible {
int r = 1;
if (c)
r = g();
return d ? r : 7;
}
```
```
clang --target=aarch64-linux-gnu -march=armv8-a+sme -O2 -c t.c # -g0
clang --target=aarch64-linux-gnu -march=armv8-a+sme -O2 -g -c t.c # -g
```
```
-g0: 44: tbz w20, #0x0, 0x54 ; to the join
-g : 44: tbz w20, #0x0, 0x4c ; to `b 0x54`
48: smstart sm
4c: b 0x54
```
The first difference is in aarch64-expand-pseudo. The if.then block ends with the conditional
smstart (`MSRpstatePseudo`) followed by the `DBG_VALUE` for `r`. `expandConditionalPseudo`
uses the fallthrough successor as the end block only when the pseudo is the last instruction:
https://github.com/llvm/llvm-project/blob/3f3bd3f9e0bc3fdb24219fbfebdc2ac4edfc3e5c/llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp#L1103-L1106
With `-g` the `DBG_VALUE` follows it, so the block is split and the new end block contains only the
`DBG_VALUE`. Block placement keeps that block, which gets the `b`. The same helper expands
`RestoreZAPseudo` and `CommitZASavePseudo`. `expandCondSMToggle` has the same
`std::next(MBBI) == MBB.end()` check for a pseudo before `unreachable` (L1195).
MIR reproducer (the second RUN adds and removes debug instructions around the pass and gets an
extra block):
```
# RUN: llc -mtriple=aarch64 -mattr=+sme -run-pass=aarch64-expand-pseudo -o - %s
# RUN: llc -mtriple=aarch64 -mattr=+sme -run-pass=mir-debugify,aarch64-expand-pseudo,mir-strip-debug -o - %s
---
name: cond_smstart_last_in_block
tracksRegLiveness: true
body: |
bb.0:
successors: %bb.1
liveins: $x8, $w0
MSRpstatePseudo 1, 1, 1, $x8, csr_aarch64_smstartstop, implicit-def dead $vg, implicit-def dead $fpmr, implicit $vg
bb.1:
liveins: $w0
RET_ReallyLR implicit $w0
...
```
Possible fixes: skip debug instructions in the check (`next_nodbg`); the trailing `DBG_VALUE`s then
stay in the conditional block and run only when the mode is toggled. Or move them above the
conditional branch so they stay on both paths. Which one would you prefer?
Reproduces on main 3f3bd3f9e0bc.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs