missing mflr/mtlr (link register save/restore) when using inline asm w/ "lr" clobber
| Bugzilla Link | 50147 |
| Resolution | FIXED |
| Resolved on | Jun 03, 2021 23:16 |
| Version | trunk |
| OS | All |
| Blocks | llvm/llvm-project#4440 llvm/llvm-project#48661 |
| CC | @nathanchance,@nemanjai,@stephenhines,@stefanp-ibm,@tstellar,@uweigand |
| Fixed by commit(s) | 15051f0b4a2e0a0af9da7cd5e5cfaabb9f6aaa3d f2ce10d14b7c |
Extended Description
example: void foo (void) { asm ("":::"lr"); }
powerpc64le-linux-gnu-gcc -O2: foo: mflr 0 std 0,16(1) ld 0,16(1) mtlr 0 blr
clang --target=powerpc64le-linux-gnu -O2: foo: blr
This is causing ppc32 Linux kernels to hang when powering down, resulting in CI failures, as reported by Nathan Chancellor and debugged by Christophe Leroy in https://lists.ozlabs.org/pipermail/linuxppc-dev/2021-April/228246.html.
Merged: f2ce10d14b7c
https://reviews.llvm.org/rG15051f0b4a2e0a0af9da7cd5e5cfaabb9f6aaa3d
Tom, could you please make sure this gets applied to release/12.x? I have verified that the issue that was initially reported is resolved and all the tests pass.
Should probably backport this to 12.0.1. Marked this bug as blocking that release.
Put up an initial patch on Phabricator: https://reviews.llvm.org/D101657
The patch should fix the issue where the LR is clobbered in inline ASM.
Yes, we are aware of this unfortunate omission in the PPC back end. In fact, this same issue exists for other special registers (R2, R1, etc.)
assigned to @stefanp-ibm