blob: 5b52e6e6aa649e0ecfe4d9b03d8ead7c5359a93e [file] [log] [blame]
Vitaly Bukac34b7aa2019-08-24 01:31:38 +00001// RUN: %clang -w -target x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0 %s | \
2// RUN: FileCheck %s -check-prefixes=CHECK,CHECK-O0 --implicit-check-not=llvm.lifetime
3// RUN: %clang -w -target x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0 \
4// RUN: -fsanitize=address -fsanitize-address-use-after-scope %s | \
5// RUN: FileCheck %s -check-prefixes=CHECK,LIFETIME
Vitaly Bukaaeca5692019-08-26 22:15:50 +00006// RUN: %clang -w -target x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0 \
7// RUN: -fsanitize=memory %s | \
8// RUN: FileCheck %s -check-prefixes=CHECK,LIFETIME
Vitaly Buka669d1112019-08-26 22:16:05 +00009// RUN: %clang -w -target aarch64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0 \
10// RUN: -fsanitize=hwaddress %s | \
11// RUN: FileCheck %s -check-prefixes=CHECK,LIFETIME
Vitaly Bukac34b7aa2019-08-24 01:31:38 +000012
13extern int bar(char *A, int n);
14
15struct X {
16 X();
17 ~X();
18 int *p;
19};
20struct Y {
21 Y();
22 int *p;
23};
24
25extern "C" void a(), b(), c(), d();
26
27// CHECK-LABEL: @_Z3foo
28void foo(int n) {
29 // CHECK-LABEL: call void @a()
30 a();
31
32 // CHECK-LABEL: call void @b()
33 // CHECK: store i1 false
34 // CHECK-LABEL: br i1
35 //
36 // CHECK-LABEL: cond.true:
37 // LIFETIME: @llvm.lifetime.start
38 // LIFETIME: store i1 true
39 // LIFETIME: call void @_ZN1XC
40 // CHECK-LABEL: br label
41 //
42 // CHECK-LABEL: cond.false:
43 // LIFETIME: @llvm.lifetime.start
44 // LIFETIME: store i1 true
45 // LIFETIME: call void @_ZN1YC
46 // CHECK-LABEL: br label
47 //
48 // CHECK-LABEL: cond.end:
49 // CHECK: call void @c()
50 // LIFETIME: @llvm.lifetime.end
51 // LIFETIME: @llvm.lifetime.end
52 b(), (n ? X().p : Y().p), c();
53
54 // CHECK: call void @d()
55 d();
56}