File: asm.cpp

package info (click to toggle)
llvm-toolchain-15 1%3A15.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,554,644 kB
  • sloc: cpp: 5,922,452; ansic: 1,012,136; asm: 674,362; python: 191,568; objc: 73,855; f90: 42,327; lisp: 31,913; pascal: 11,973; javascript: 10,144; sh: 9,421; perl: 7,447; ml: 5,527; awk: 3,523; makefile: 2,520; xml: 885; cs: 573; fortran: 567
file content (52 lines) | stat: -rw-r--r-- 1,614 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// RUN: %clang_cc1 -triple i386-unknown-unknown -fblocks -emit-llvm %s -o - | FileCheck %s

// CHECK: %[[STRUCT_A:.*]] = type { i8 }

struct A
{
    ~A();
};
int foo(A);

void bar(A &a)
{
    // CHECK: call void asm
    asm("" : : "r"(foo(a)) ); // rdar://8540491
    // CHECK: call void @_ZN1AD1Ev
}

namespace TestTemplate {
// Check that the temporary is destructed after the first asm statement.

// CHECK: define {{.*}}void @_ZN12TestTemplate4foo0IvEEvR1A(
// CHECK: %[[AGG_TMP:.*]] = alloca %[[STRUCT_A]],
// CHECK: %[[CALL:.*]] = call noundef i32 @_Z3foo1A({{.*}}%[[AGG_TMP]])
// CHECK: call void asm sideeffect "", "r,~{dirflag},~{fpsr},~{flags}"(i32 %[[CALL]])
// CHECK: call void @_ZN1AD1Ev({{.*}}%[[AGG_TMP]])
// CHECK: call void asm sideeffect "",

template <class T>
void foo0(A &a) {
  asm("" : : "r"(foo(a)) );
  asm("");
}

void test0(A &a) { foo0<void>(a); }

// Check that the block capture is destructed at the end of the enclosing scope.

// CHECK: define {{.*}}void @_ZN12TestTemplate4foo1IvEEv1A(
// CHECK: %[[BLOCK:.*]] = alloca <{ ptr, i32, i32, ptr, ptr, %[[STRUCT_A]] }>, align 4
// CHECK: %[[BLOCK_CAPTURED:.*]] = getelementptr inbounds <{ ptr, i32, i32, ptr, ptr, %[[STRUCT_A]] }>, ptr %[[BLOCK]], i32 0, i32 5
// CHECK: call void asm sideeffect "", "r,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
// CHECK: call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"()
// CHECK: call void @_ZN1AD1Ev({{.*}} %[[BLOCK_CAPTURED]])

template <class T>
void foo1(A a) {
  asm("" : : "r"(^{ (void)a; return 0; }()));
  asm("");
}

void test1(A &a) { foo1<void>(a); }
} // namespace TestTemplate