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
This commit is contained in:
Reid Kleckner 2014-08-01 20:23:29 +00:00
parent f3bd7cfdd7
commit fded34de2a
3 changed files with 63 additions and 3 deletions

View File

@ -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
}

View File

@ -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)
}

View File

@ -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.