summaryrefslogtreecommitdiff
path: root/test/CodeGen
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-08-01 20:23:29 +0000
committerReid Kleckner <reid@kleckner.net>2014-08-01 20:23:29 +0000
commitfded34de2a2e700ce7d36d1778c075c363b37ae7 (patch)
treec71db2c60973286db662d300e0a0eb8cb56c5f76 /test/CodeGen
parentf3bd7cfdd7b077bb2f05f21f25f7865262f209b3 (diff)
downloadclang-fded34de2a2e700ce7d36d1778c075c363b37ae7.tar.gz
MS inline asm: Tests for r214550
These tests seem like an exception to the rule against assembly emitting tests in clang. I made an LLVM side change that can only be tested by setting up the inline assembly machinery that is only implemented by Clang. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214552 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen')
-rw-r--r--test/CodeGen/ms-inline-asm-functions.c60
-rw-r--r--test/CodeGen/ms-inline-asm.c4
-rw-r--r--test/CodeGen/ms-inline-asm.cpp2
3 files changed, 63 insertions, 3 deletions
diff --git a/test/CodeGen/ms-inline-asm-functions.c b/test/CodeGen/ms-inline-asm-functions.c
new file mode 100644
index 0000000000..1a6ead9286
--- /dev/null
+++ b/test/CodeGen/ms-inline-asm-functions.c
@@ -0,0 +1,60 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -triple i386-pc-windows-msvc -fms-extensions -S -o - | FileCheck %s
+
+// Yes, this is an assembly test from Clang, because we need to make it all the
+// way through code generation to know if our call became a direct, pc-relative
+// call or an indirect call through memory.
+
+int k(int);
+__declspec(dllimport) int kimport(int);
+int (*kptr)(int);
+int (*gptr())(int);
+
+int foo() {
+ // CHECK-LABEL: _foo:
+ int (*r)(int) = gptr();
+
+ // Simple case: direct call.
+ __asm call k;
+ // CHECK: calll _k
+
+ // Marginally harder: indirect calls, via dllimport or function pointer.
+ __asm call r;
+ // CHECK: calll *({{.*}})
+ __asm call kimport;
+ // CHECK: calll *({{.*}})
+
+ // Broken case: Call through a global function pointer.
+ __asm call kptr;
+ // CHECK: calll _kptr
+ // CHECK-FIXME: calll *_kptr
+}
+
+int bar() {
+ // CHECK-LABEL: _bar:
+ __asm jmp k;
+ // CHECK: jmp _k
+}
+
+int baz() {
+ // CHECK-LABEL: _baz:
+ __asm mov eax, k;
+ // CHECK: movl _k, %eax
+ __asm mov eax, kptr;
+ // CHECK: movl _kptr, %eax
+}
+
+// Test that this asm blob doesn't require more registers than available. This
+// has to be an LLVM code generation test.
+
+void __declspec(naked) naked() {
+ __asm pusha
+ __asm call k
+ __asm popa
+ __asm ret
+ // CHECK-LABEL: _naked:
+ // CHECK: pushal
+ // CHECK-NEXT: calll _k
+ // CHECK-NEXT: popal
+ // CHECK-NEXT: retl
+}
diff --git a/test/CodeGen/ms-inline-asm.c b/test/CodeGen/ms-inline-asm.c
index 06c0db8ebc..92158e0cb9 100644
--- a/test/CodeGen/ms-inline-asm.c
+++ b/test/CodeGen/ms-inline-asm.c
@@ -246,7 +246,7 @@ void t24_helper(void) {}
void t24() {
__asm call t24_helper
// CHECK: t24
-// CHECK: call void asm sideeffect inteldialect "call $0", "r,~{dirflag},~{fpsr},~{flags}"(void ()* @t24_helper)
+// CHECK: call void asm sideeffect inteldialect "call dword ptr $0", "*m,~{dirflag},~{fpsr},~{flags}"(void ()* @t24_helper)
}
void t25() {
@@ -508,5 +508,5 @@ void t41(unsigned short a) {
void call_clobber() {
__asm call t41
// CHECK-LABEL: define void @call_clobber
- // CHECK: call void asm sideeffect inteldialect "call $0", "r,~{dirflag},~{fpsr},~{flags}"(void (i16)* @t41)
+ // CHECK: call void asm sideeffect inteldialect "call dword ptr $0", "*m,~{dirflag},~{fpsr},~{flags}"(void (i16)* @t41)
}
diff --git a/test/CodeGen/ms-inline-asm.cpp b/test/CodeGen/ms-inline-asm.cpp
index 7bd6d9435e..65e59d6b94 100644
--- a/test/CodeGen/ms-inline-asm.cpp
+++ b/test/CodeGen/ms-inline-asm.cpp
@@ -82,7 +82,7 @@ void test5() {
__asm push y
__asm call T5<int>::create<float>
__asm mov x, eax
- // CHECK: call void asm sideeffect inteldialect "push dword ptr $0\0A\09call $2\0A\09mov dword ptr $1, eax", "=*m,=*m,r,~{esp},~{dirflag},~{fpsr},~{flags}"(i32* %y, i32* %x, i32 (float)* @_ZN2T5IiE6createIfEEiT_)
+ // CHECK: call void asm sideeffect inteldialect "push dword ptr $0\0A\09call dword ptr $2\0A\09mov dword ptr $1, eax", "=*m,=*m,*m,~{esp},~{dirflag},~{fpsr},~{flags}"(i32* %y, i32* %x, i32 (float)* @_ZN2T5IiE6createIfEEiT_)
}
// Just verify this doesn't emit an error.