llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

missing mflr/mtlr (link register save/restore) when using inline asm w/ "lr" clobber

Open nickdesaulniers opened this issue 5 years ago • 6 comments

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.

nickdesaulniers avatar Apr 27 '21 20:04 nickdesaulniers

Merged: f2ce10d14b7c

tstellar avatar Jun 04 '21 06:06 tstellar

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.

nathanchance avatar May 13 '21 19:05 nathanchance

Should probably backport this to 12.0.1. Marked this bug as blocking that release.

stefanp-synopsys avatar May 03 '21 10:05 stefanp-synopsys

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.

stefanp-synopsys avatar Apr 30 '21 20:04 stefanp-synopsys

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.)

nemanjai avatar Apr 28 '21 14:04 nemanjai

assigned to @stefanp-ibm

nickdesaulniers avatar Apr 27 '21 20:04 nickdesaulniers