xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/dllimport.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple i386-pc-win32 < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple i386-pc-mingw32 < %s | FileCheck %s
3*9880d681SAndroid Build Coastguard Worker;
4*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple i386-pc-mingw32 -O0 < %s | FileCheck %s -check-prefix=FAST
5*9880d681SAndroid Build Coastguard Worker; PR6275
6*9880d681SAndroid Build Coastguard Worker;
7*9880d681SAndroid Build Coastguard Worker; RUN: opt -mtriple i386-pc-win32 -O3 -S < %s | FileCheck %s -check-prefix=OPT
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Worker@Var1 = external dllimport global i32
10*9880d681SAndroid Build Coastguard Worker@Var2 = available_externally dllimport unnamed_addr constant i32 1
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Workerdeclare dllimport void @fun()
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Workerdefine available_externally dllimport void @inline1() {
15*9880d681SAndroid Build Coastguard Worker	ret void
16*9880d681SAndroid Build Coastguard Worker}
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard Workerdefine available_externally dllimport void @inline2() alwaysinline {
19*9880d681SAndroid Build Coastguard Worker	ret void
20*9880d681SAndroid Build Coastguard Worker}
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Workerdeclare dllimport x86_stdcallcc void @stdfun() nounwind
23*9880d681SAndroid Build Coastguard Workerdeclare dllimport x86_fastcallcc void @fastfun() nounwind
24*9880d681SAndroid Build Coastguard Workerdeclare dllimport x86_thiscallcc void @thisfun() nounwind
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard Workerdeclare void @dummy(...)
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Workerdefine void @use() nounwind {
29*9880d681SAndroid Build Coastguard Worker; CHECK:     calll *__imp__fun
30*9880d681SAndroid Build Coastguard Worker; FAST:      movl  __imp__fun, [[R:%[a-z]{3}]]
31*9880d681SAndroid Build Coastguard Worker; FAST-NEXT: calll *[[R]]
32*9880d681SAndroid Build Coastguard Worker  call void @fun()
33*9880d681SAndroid Build Coastguard Worker
34*9880d681SAndroid Build Coastguard Worker; CHECK: calll *__imp__inline1
35*9880d681SAndroid Build Coastguard Worker; CHECK: calll *__imp__inline2
36*9880d681SAndroid Build Coastguard Worker  call void @inline1()
37*9880d681SAndroid Build Coastguard Worker  call void @inline2()
38*9880d681SAndroid Build Coastguard Worker
39*9880d681SAndroid Build Coastguard Worker; CHECK: calll *__imp__stdfun@0
40*9880d681SAndroid Build Coastguard Worker; CHECK: calll *__imp_@fastfun@0
41*9880d681SAndroid Build Coastguard Worker; CHECK: calll *__imp__thisfun
42*9880d681SAndroid Build Coastguard Worker  call void @stdfun()
43*9880d681SAndroid Build Coastguard Worker  call void @fastfun()
44*9880d681SAndroid Build Coastguard Worker  call void @thisfun()
45*9880d681SAndroid Build Coastguard Worker
46*9880d681SAndroid Build Coastguard Worker; available_externally uses go away
47*9880d681SAndroid Build Coastguard Worker; OPT-NOT: call void @inline1()
48*9880d681SAndroid Build Coastguard Worker; OPT-NOT: call void @inline2()
49*9880d681SAndroid Build Coastguard Worker; OPT-NOT: load i32, i32* @Var2
50*9880d681SAndroid Build Coastguard Worker; OPT: call void (...) @dummy(i32 %1, i32 1)
51*9880d681SAndroid Build Coastguard Worker
52*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: movl __imp__Var1, [[R1:%[a-z]{3}]]
53*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: movl __imp__Var2, [[R2:%[a-z]{3}]]
54*9880d681SAndroid Build Coastguard Worker  %1 = load i32, i32* @Var1
55*9880d681SAndroid Build Coastguard Worker  %2 = load i32, i32* @Var2
56*9880d681SAndroid Build Coastguard Worker  call void(...) @dummy(i32 %1, i32 %2)
57*9880d681SAndroid Build Coastguard Worker
58*9880d681SAndroid Build Coastguard Worker  ret void
59*9880d681SAndroid Build Coastguard Worker}
60*9880d681SAndroid Build Coastguard Worker
61*9880d681SAndroid Build Coastguard Worker; CHECK: _fp:
62*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: .long _fun
63*9880d681SAndroid Build Coastguard Worker@fp = constant void ()* @fun
64