1 ; RUN: llc -mtriple aarch64-unknown-windows-msvc -filetype asm -o - %s | FileCheck %s -check-prefixes=CHECK,DAG-ISEL
2 ; RUN: llc -mtriple aarch64-unknown-windows-msvc -fast-isel -filetype asm -o - %s | FileCheck %s -check-prefixes=CHECK,FAST-ISEL
3 ; RUN: llc -mtriple aarch64-unknown-windows-msvc -verify-machineinstrs -O0 -filetype asm -o - %s | FileCheck %s -check-prefixes=CHECK,GLOBAL-ISEL,GLOBAL-ISEL-FALLBACK
5 @var = external dllimport global i32
6 @ext = external global i32
7 declare dllimport i32 @external()
8 declare i32 @internal()
10 define i32 @get_var() {
11 %1 = load i32, ptr @var, align 4
15 ; CHECK-LABEL: get_var
16 ; CHECK: adrp x8, __imp_var
17 ; CHECK: ldr x8, [x8, :lo12:__imp_var]
21 define i32 @get_ext() {
22 %1 = load i32, ptr @ext, align 4
26 ; CHECK-LABEL: get_ext
28 ; DAG-ISEL: ldr w0, [x8, :lo12:ext]
29 ; FAST-ISEL: add x8, x8, :lo12:ext
30 ; FAST-ISEL: ldr w0, [x8]
31 ; GLOBAL-ISEL-FALLBACK: ldr w0, [x8, :lo12:ext]
34 define ptr @get_var_pointer() {
38 ; CHECK-LABEL: get_var_pointer
39 ; CHECK: adrp [[REG1:x[0-9]+]], __imp_var
40 ; CHECK: ldr {{x[0-9]+}}, [[[REG1]], :lo12:__imp_var]
43 define i32 @call_external() {
44 %call = tail call i32 @external()
48 ; CHECK-LABEL: call_external
49 ; CHECK: adrp x0, __imp_external
50 ; CHECK: ldr x0, [x0, :lo12:__imp_external]
53 define i32 @call_internal() {
54 %call = tail call i32 @internal()
58 ; CHECK-LABEL: call_internal
59 ; DAG-ISEL: b internal
60 ; FAST-ISEL: b internal
61 ; GLOBAL-ISEL: b internal
63 define void @call_try_catch() personality ptr @__gxx_personality_seh0 {
66 to label %try.cont unwind label %lpad
68 lpad: ; preds = %entry
69 %0 = landingpad { ptr, i32 }
71 %1 = extractvalue { ptr, i32 } %0, 1
72 %2 = tail call i32 @llvm.eh.typeid.for(ptr nonnull @_ZTIi) #1
73 %matches = icmp eq i32 %1, %2
74 br i1 %matches, label %catch, label %eh.resume
76 catch: ; preds = %lpad
77 %3 = extractvalue { ptr, i32 } %0, 0
78 %4 = tail call ptr @__cxa_begin_catch(ptr %3) #1
79 tail call void @__cxa_end_catch() #1
82 try.cont: ; preds = %entry, %catch
85 eh.resume: ; preds = %lpad
86 resume { ptr, i32 } %0
89 ; CHECK-LABEL: call_try_catch
90 ; CHECK: adrp x8, __imp_myFunc
91 ; CHECK: ldr x8, [x8, :lo12:__imp_myFunc]
94 declare dllimport void @myFunc()
96 @_ZTIi = external constant ptr
97 declare dso_local i32 @__gxx_personality_seh0(...)
98 declare i32 @llvm.eh.typeid.for(ptr) #0
99 declare dso_local ptr @__cxa_begin_catch(ptr)
100 declare dso_local void @__cxa_end_catch()
102 attributes #0 = { nounwind memory(none) }
103 attributes #1 = { nounwind }