[LLVMbugs] [Bug 17023] New: [Win64][cygming] calling @__main is mis-assumed not to clobber registers (esp. rax, rcx, rdx)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Aug 28 06:53:11 PDT 2013


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: unassignedbugs at nondot.org
          Reporter: geek4civic at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130828/ec1f2fca/attachment.html>


More information about the llvm-bugs mailing list