http://llvm.org/bugs/show_bug.cgi?id=13563
Bug #: 13563
Summary: miscompile of trivial sret example at -O0
Product: libraries
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
Classification: Unclassified
This tiny example:
target datalayout =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
declare i8* @f() nounwind uwtable
define void @g(i8* noalias sret %result) nounwind uwtable {
bb:
%a = alloca i8
%b = call i8* @f()
ret void
}
is miscompiled at llc -O0, but not llc -O2. We produce
g: # @g
subq $24, %rsp
movq %rdi, 8(%rsp) # 8-byte Spill
callq f
movq %rax, (%rsp) # 8-byte Spill
addq $24, %rsp
ret
which does not maintain the ABI guarantee that the value in %rax is the value
we were given in %rdi. Building with llc -O2 however, emits correct code:
g: # @g
pushq %rbx
subq $16, %rsp
movq %rdi, %rbx
callq f
movq %rbx, %rax
addq $16, %rsp
popq %rbx
ret
though it could be more optimal via. pushq %rdi / popq %rax and no wrangling
with %rbx at all.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs