[RISCV] Add shrinkwrap test cases showing gaps in current impl
[llvm-project.git] / clang / test / CodeGenCXX / asm.cpp
blob947ac32cf44a0b35cb7f5fc09e6871e869471d54
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)) );
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 nuw <{ 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