| Issue |
244909
|
| Summary |
[AArch64] Debug info changes the homogeneous epilog helper (-homogeneous-prolog-epilog)
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
yqtian-se
|
With `-mllvm -homogeneous-prolog-epilog`, `-g` changes which epilog helper is used:
```c
int g(int);
int f(int x) {
int r = x * 7;
if (x > 5) {
r = g(x);
r = g(r) + r;
}
int u = r + 1;
return r;
}
```
```
clang --target=arm64-apple-ios -Oz -mllvm -homogeneous-prolog-epilog -c t.c # -g0
clang --target=arm64-apple-ios -Oz -mllvm -homogeneous-prolog-epilog -g -c t.c # -g
```
```
-g0: b _OUTLINED_FUNCTION_EPILOG_TAIL_x30x29x19x20
-g : bl _OUTLINED_FUNCTION_EPILOG_x30x29x19x20
ret
```
Shrink-wrapping puts the frame in the `if` block, and tail duplication copies the return block
(`DBG_VALUE` for `u`, then `RET_ReallyLR`) after `HOM_Epilog`. `shouldUseFrameHelper` uses the
tail helper only if the instruction right after `HOM_Epilog` is `RET_ReallyLR`, so the `DBG_VALUE`
makes it pick the non-tail helper:
https://github.com/llvm/llvm-project/blob/3f3bd3f9e0bc3fdb24219fbfebdc2ac4edfc3e5c/llvm/lib/Target/AArch64/AArch64LowerHomogeneousPrologEpilog.cpp#L436-L441
The non-tail check in the same function scans for a read of X16 and also counts a
`DBG_VALUE $w16`.
The same difference shows with `llc` alone, on the IR of this function with and without
`opt -passes=debugify`.
Skipping debug instructions in the checks is not enough on its own: `lowerEpilog` would then put
the tail call where `HOM_Epilog` was, leaving the `DBG_VALUE` after a terminator. A fix could skip
debug instructions in both checks and insert the tail call at the return instead. I can put up a
PR with that and a debugify test if this looks right.
Reproduces on main 3f3bd3f9e0bc.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs