brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 947ac32 Raw
53 lines · cpp
1// RUN: %clang_cc1 -triple i386-unknown-unknown -fblocks -emit-llvm %s -o - | FileCheck %s2 3// CHECK: %[[STRUCT_A:.*]] = type { i8 }4 5struct A6{7    ~A();8};9int foo(A);10 11void bar(A &a)12{13    // CHECK: call void asm14    asm("" : : "r"(foo(a)) );15    // CHECK: call void @_ZN1AD1Ev16}17 18namespace 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 28template <class T>29void foo0(A &a) {30  asm("" : : "r"(foo(a)) );31  asm("");32}33 34void 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 440// CHECK: %[[BLOCK_CAPTURED:.*]] = getelementptr inbounds nuw <{ ptr, i32, i32, ptr, ptr, %[[STRUCT_A]] }>, ptr %[[BLOCK]], i32 0, i32 541// 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 45template <class T>46void foo1(A a) {47  asm("" : : "r"(^{ (void)a; return 0; }()));48  asm("");49}50 51void test1(A &a) { foo1<void>(a); }52} // namespace TestTemplate53