1 // RUN: %clang_cc1 -triple i386-unknown-unknown -fblocks -emit-llvm %s -o - | FileCheck %s 2 3 // CHECK: %[[STRUCT_A:.*]] = type { i8 } 4 5 struct A 6 { 7 ~A(); 8 }; 9 int foo(A); 10 11 void bar(A &a) 12 { 13 // CHECK: call void asm 14 asm("" : : "r"(foo(a)) ); 15 // CHECK: call void @_ZN1AD1Ev 16 } 17 18 namespace TestTemplate { 19 // Check that the temporary is destructed after the first asm statement. 20 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 "", 27 28 template <class T> 29 void foo0(A &a) { 30 asm("" : : "r"(foo(a)) ); 31 asm(""); 32 } 33 34 void test0(A &a) { foo0<void>(a); } 35 36 // Check that the block capture is destructed at the end of the enclosing scope. 37 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]]) 44 45 template <class T> 46 void foo1(A a) { 47 asm("" : : "r"(^{ (void)a; return 0; }())); 48 asm(""); 49 } 50 51 void test1(A &a) { foo1<void>(a); } 52 } // namespace TestTemplate 53