Description
Bugzilla Link | 6275 |
Resolution | FIXED |
Resolved on | Feb 20, 2011 23:58 |
Version | trunk |
OS | Windows NT |
Blocks | llvm/llvm-bugzilla-archive#8390 |
Reporter | LLVM Bugzilla Contributor |
CC | @efriedma-quic,@sunfishcode |
Extended Description
In investigating #6641 , we stumbled onto some very weird behavior regarding codegen of calls to dllimport functions.
Running Amine's example from #6641 :
attribute((dllimport)) void foo(int);
void bar(void) {foo(0);}
through clang with:
clang -cc1 -triple=i386-mingw32 -S dllimp.c
produces:
.def _bar; .scl 2; .type 32; .endef
.text
.globl _bar
.align 16
_bar:
subl $4, %esp
movl $0, (%esp)
call _foo
addl $4, %esp
ret
.def _foo; .scl 2; .type 32; .endef
But oddly enough, there's nothing wrong with the LLVM IR that clang is generating:
; ModuleID = 'test-dll.c'
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f80:128:128-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
target triple = "i386-mingw32"
define void @bar() nounwind {
entry:
call void @foo(i32 0)
ret void
}
declare dllimport void @foo(i32)
And compiling this to x86 assembly with llc produces the correct output:
.def _bar; .scl 2; .type 32; .endef
.text
.globl _bar
.align 16
_bar: # @bar
BB#0: # %entry
subl $4, %esp
movl $0, (%esp)
call *__imp__foo
addl $4, %esp
ret
.def _foo; .scl 2; .type 32; .endef
If I had a mingw32 version of llvm-gcc, I'd test it with that too just for comparison, but I don't.