summaryrefslogtreecommitdiff
path: root/test/CodeGen/AArch64
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2017-10-25 07:25:18 +0000
committerMartin Storsjo <martin@martin.st>2017-10-25 07:25:18 +0000
commit1efa535c779f2f59e8b798c93cbdd9078eef149d (patch)
treea253fa455e6c15e24a609404de86a66a2f07c5ab /test/CodeGen/AArch64
parent7bb5f9ead4d2bbd386134e8a85caf881ad498443 (diff)
[AArch64] Add support for dllimport of values and functions
Previously, the dllimport attribute did the right thing in terms of treating it as a pointer to a value, but this makes sure the names get mangled properly, and calls to such functions load the function from the __imp_ pointer. This is based on SVN r212431 and r212430 where the same was implemented for ARM. Differential Revision: https://reviews.llvm.org/D38530 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316555 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/AArch64')
-rw-r--r--test/CodeGen/AArch64/dllimport.ll54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/CodeGen/AArch64/dllimport.ll b/test/CodeGen/AArch64/dllimport.ll
new file mode 100644
index 00000000000..fad049a54cd
--- /dev/null
+++ b/test/CodeGen/AArch64/dllimport.ll
@@ -0,0 +1,54 @@
+; RUN: llc -mtriple aarch64-unknown-windows-msvc -filetype asm -o - %s | FileCheck %s
+
+@var = external dllimport global i32
+@ext = external global i32
+declare dllimport i32 @external()
+declare i32 @internal()
+
+define i32 @get_var() {
+ %1 = load i32, i32* @var, align 4
+ ret i32 %1
+}
+
+; CHECK-LABEL: get_var
+; CHECK: adrp x8, __imp_var
+; CHECK: ldr x8, [x8, __imp_var]
+; CHECK: ldr w0, [x8]
+; CHECK: ret
+
+define i32 @get_ext() {
+ %1 = load i32, i32* @ext, align 4
+ ret i32 %1
+}
+
+; CHECK-LABEL: get_ext
+; CHECK: adrp x8, ext
+; CHECK: ldr w0, [x8, ext]
+; CHECK: ret
+
+define i32* @get_var_pointer() {
+ ret i32* @var
+}
+
+; CHECK-LABEL: get_var_pointer
+; CHECK: adrp x0, __imp_var
+; CHECK: ldr x0, [x0, __imp_var]
+; CHECK: ret
+
+define i32 @call_external() {
+ %call = tail call i32 @external()
+ ret i32 %call
+}
+
+; CHECK-LABEL: call_external
+; CHECK: adrp x0, __imp_external
+; CHECK: ldr x0, [x0, __imp_external]
+; CHECK: br x0
+
+define i32 @call_internal() {
+ %call = tail call i32 @internal()
+ ret i32 %call
+}
+
+; CHECK-LABEL: call_internal
+; CHECK: b internal