http://llvm.org/bugs/show_bug.cgi?id=17023
Bug ID: 17023
Summary: [Win64][cygming] calling @__main is mis-assumed not to
clobber registers (esp. rax, rcx, rdx)
Product: libraries
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Backend: X86
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
@__main is inserted in @main for targeting cygming, also on x86_64
; %c is passed via %rcx.
define i32 @main(i32 %c, i8** nocapture readnone %v) nounwind readnone {
; tail call void asm sideeffect "nop",
"r,~{rcx},~{dirflag},~{fpsr},~{flags}"(i32 %c) nounwind
%cmp = icmp eq i32 %c, 2
%cond = select i1 %cmp, i32 2, i32 0
ret i32 %cond
}
$ llc -mtriple=x86_64-mingw32
; w/o asm
main:
pushq %rbp
movq %rsp, %rbp
callq __main
cmpl $2, %ecx ; XXX might be clobbered in __main!
; w/asm (uncomment the line)
main: # @main
# BB#0:
pushq %rbp
movq %rsp, %rbp
movl %ecx, %eax
callq __main ; XXX it must clobber %rax!
#APP
nop
#NO_APP
cmpl $2, %eax
We should teach, in X86DAGToDAGISel::EmitSpecialCodeForMain(),
that __main should be treated as same as generic CC_X86_Win64_C.
IMO, we could consider that clang might be responsible to insert @__main,
instead of llvm codegen.
--
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