1; RUN: llc -mtriple x86_64-pc-win32 < %s | FileCheck %s
2; RUN: llc -mtriple x86_64-pc-mingw32 < %s | FileCheck %s
3;
4; RUN: llc -mtriple x86_64-pc-mingw32 -O0 < %s | FileCheck %s -check-prefix=FAST
5; PR6275
6;
7; RUN: opt -mtriple x86_64-pc-win32 -O3 -S < %s | FileCheck %s -check-prefix=OPT
8
9@Var1 = external dllimport global i32
10@Var2 = available_externally dllimport unnamed_addr constant i32 1
11
12declare dllimport void @fun()
13
14define available_externally dllimport void @inline1() {
15	ret void
16}
17
18define available_externally dllimport void @inline2() {
19	ret void
20}
21
22declare void @dummy(...)
23
24define void @use() nounwind {
25; CHECK:     callq *__imp_fun(%rip)
26; FAST:      movq  __imp_fun(%rip), [[R:%[a-z]{3}]]
27; FAST-NEXT: callq *[[R]]
28  call void @fun()
29
30; CHECK: callq *__imp_inline1(%rip)
31; CHECK: callq *__imp_inline2(%rip)
32  call void @inline1()
33  call void @inline2()
34
35; available_externally uses go away
36; OPT-NOT: call void @inline1()
37; OPT-NOT: call void @inline2()
38; OPT-NOT: load i32, i32* @Var2
39; OPT: call void (...) @dummy(i32 %1, i32 1)
40
41; CHECK-DAG: movq __imp_Var1(%rip), [[R1:%[a-z]{3}]]
42; CHECK-DAG: movq __imp_Var2(%rip), [[R2:%[a-z]{3}]]
43  %1 = load i32, i32* @Var1
44  %2 = load i32, i32* @Var2
45  call void(...) @dummy(i32 %1, i32 %2)
46
47  ret void
48}
49