<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - [Win64][cygming] calling @__main is mis-assumed not to clobber registers (esp. rax, rcx, rdx)"
   href="http://llvm.org/bugs/show_bug.cgi?id=17023">17023</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[Win64][cygming] calling @__main is mis-assumed not to clobber registers (esp. rax, rcx, rdx)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>geek4civic@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>@__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.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>