<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 --- - Incorrect calling convention at -O0 for x86_64-pc-win32 target"
   href="http://llvm.org/bugs/show_bug.cgi?id=15514">15514</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Incorrect calling convention at -O0 for x86_64-pc-win32 target
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows XP
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </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>jlerouge@apple.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>On the following IR:

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-pc-win32"

define i32 @foo(i32* %p) {
entry:
  %0 = load i32* %p, align 4
  ret i32 %0
}

define i32 @main(i32 %argc, i8** %argv) {
entry:
  %argc.addr = alloca i32, align 4
  store i32 %argc, i32* %argc.addr, align 4
  %call = call i32 @foo(i32* %argc.addr)
  ret i32 %call
}


llc -O0 produces this for foo:

    .def     foo;
    .scl    2;
    .type    32;
    .endef
    .text
    .globl    foo
    .align    16, 0x90
foo:                                    # @foo
# BB#0:                                 # %entry
    pushq    %rdi
    pushq    %rax
    movq    %rdi, (%rsp)
    movl    (%rdi), %eax
    addq    $8, %rsp
    popq    %rdi
    re

llc -O1 produces the correct output.

So, it looks like -O0 is using the wrong calling convention (argument should be
in %rcx, not %rdi). Since this only happens at -O0, it could be something in
X86FastISel.</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>