[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / asm.cpp
blobbc639a2be58774bc1f706ccbef0c109757d26295
1 // RUN: %clang_cc1 -triple i386-unknown-unknown -fblocks -emit-llvm %s -o - | FileCheck %s
3 // CHECK: %[[STRUCT_A:.*]] = type { i8 }
5 struct A
7 ~A();
8 };
9 int foo(A);
11 void bar(A &a)
13 // CHECK: call void asm
14 asm("" : : "r"(foo(a)) ); // rdar://8540491
15 // CHECK: call void @_ZN1AD1Ev
18 namespace TestTemplate {
19 // Check that the temporary is destructed after the first asm statement.
21 // CHECK: define {{.*}}void @_ZN12TestTemplate4foo0IvEEvR1A(
22 // CHECK: %[[AGG_TMP:.*]] = alloca %[[STRUCT_A]],
23 // CHECK: %[[CALL:.*]] = call noundef i32 @_Z3foo1A({{.*}}%[[AGG_TMP]])
24 // CHECK: call void asm sideeffect "", "r,~{dirflag},~{fpsr},~{flags}"(i32 %[[CALL]])
25 // CHECK: call void @_ZN1AD1Ev({{.*}}%[[AGG_TMP]])
26 // CHECK: call void asm sideeffect "",
28 template <class T>
29 void foo0(A &a) {
30 asm("" : : "r"(foo(a)) );
31 asm("");
34 void test0(A &a) { foo0<void>(a); }
36 // Check that the block capture is destructed at the end of the enclosing scope.
38 // CHECK: define {{.*}}void @_ZN12TestTemplate4foo1IvEEv1A(
39 // CHECK: %[[BLOCK:.*]] = alloca <{ ptr, i32, i32, ptr, ptr, %[[STRUCT_A]] }>, align 4
40 // CHECK: %[[BLOCK_CAPTURED:.*]] = getelementptr inbounds <{ ptr, i32, i32, ptr, ptr, %[[STRUCT_A]] }>, ptr %[[BLOCK]], i32 0, i32 5
41 // CHECK: call void asm sideeffect "", "r,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
42 // CHECK: call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"()
43 // CHECK: call void @_ZN1AD1Ev({{.*}} %[[BLOCK_CAPTURED]])
45 template <class T>
46 void foo1(A a) {
47 asm("" : : "r"(^{ (void)a; return 0; }()));
48 asm("");
51 void test1(A &a) { foo1<void>(a); }
52 } // namespace TestTemplate