r214552 - MS inline asm: Tests for r214550
Reid Kleckner
reid at kleckner.net
Fri Aug 1 13:23:29 PDT 2014
Author: rnk
Date: Fri Aug 1 15:23:29 2014
New Revision: 214552
URL: http://llvm.org/viewvc/llvm-project?rev=214552&view=rev
Log:
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.
Added:
cfe/trunk/test/CodeGen/ms-inline-asm-functions.c
Modified:
cfe/trunk/test/CodeGen/ms-inline-asm.c
cfe/trunk/test/CodeGen/ms-inline-asm.cpp
Added: cfe/trunk/test/CodeGen/ms-inline-asm-functions.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm-functions.c?rev=214552&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/ms-inline-asm-functions.c (added)
+++ cfe/trunk/test/CodeGen/ms-inline-asm-functions.c Fri Aug 1 15:23:29 2014
@@ -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
+}
Modified: cfe/trunk/test/CodeGen/ms-inline-asm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.c?rev=214552&r1=214551&r2=214552&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/ms-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm.c Fri Aug 1 15:23:29 2014
@@ -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)
}
Modified: cfe/trunk/test/CodeGen/ms-inline-asm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm.cpp?rev=214552&r1=214551&r2=214552&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/ms-inline-asm.cpp (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm.cpp Fri Aug 1 15:23:29 2014
@@ -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.
More information about the cfe-commits
mailing list