[llvm-bugs] [Bug 47812] New: CTR not correctly saved for inline assembly clobbering CTR
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Oct 12 16:52:40 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=47812
Bug ID: 47812
Summary: CTR not correctly saved for inline assembly clobbering
CTR
Product: libraries
Version: 11.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Backend: PowerPC
Assignee: unassignedbugs at nondot.org
Reporter: programmerjake at gmail.com
CC: llvm-bugs at lists.llvm.org, nemanja.i.ibm at gmail.com
The following IR is miscompiled:
https://gcc.godbolt.org/z/s5zcae
target triple = "powerpc64le-unknown-linux-gnu"
define void @f(void()* %fn) {
call void asm sideeffect "mtctr 31", "~{ctr}"()
tail call void %fn()
ret void
}
Generated Assembly (trimmed to just f's instructions, comments added):
f:
.Lfunc_gep0:
addis 2, 12, .TOC.-.Lfunc_gep0 at ha
addi 2, 2, .TOC.-.Lfunc_gep0 at l
mflr 0
std 0, 16(1)
stdu 1, -32(1)
std 2, 24(1)
mtctr 3
mr 12, 3
mtctr 31 # note how ctr not restored before the call on next line
bctrl
ld 2, 24(1)
addi 1, 1, 32
ld 0, 16(1)
mtlr 0
blr
This causes f to call whatever address was in r31 instead of %fn despite the
inline assembly including ctr in the clobber list.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201012/734af703/attachment.html>
More information about the llvm-bugs
mailing list