Debian Codegraph @

clang/test/CodeGenCXX/lifetime-sanitizer.cpp

raw
1 // RUN: %clang -w -target x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0 \
2 // RUN: -Xclang -disable-llvm-passes %s | FileCheck %s -check-prefixes=CHECK \
3 // RUN: --implicit-check-not=llvm.lifetime
4 // RUN: %clang -w -target x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0 \
5 // RUN: -fsanitize=address -fsanitize-address-use-after-scope \
6 // RUN: -Xclang -disable-llvm-passes %s | FileCheck %s -check-prefixes=CHECK,LIFETIME
7 // RUN: %clang -w -target x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0 \
8 // RUN: -fsanitize=kernel-address -fsanitize-address-use-after-scope \
9 // RUN: -Xclang -disable-llvm-passes %s | FileCheck %s -check-prefixes=CHECK,LIFETIME
10 // RUN: %clang -w -target x86_64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0 \
11 // RUN: -fsanitize=memory -Xclang -disable-llvm-passes %s | \
12 // RUN: FileCheck %s -check-prefixes=CHECK,LIFETIME
13 // RUN: %clang -w -target aarch64-linux-gnu -S -emit-llvm -o - -fno-exceptions -O0 \
14 // RUN: -fsanitize=hwaddress -Xclang -disable-llvm-passes %s | \
15 // RUN: FileCheck %s -check-prefixes=CHECK,LIFETIME
16
17 extern int bar(char *A, int n);
18
19 struct X {
20 X();
21 ~X();
22 int *p;
23 };
24 struct Y {
25 Y();
26 int *p;
27 };
28
29 extern "C" void a(), b(), c(), d();
30
31 // CHECK: define dso_local void @_Z3fooi(i32 noundef %[[N:[^)]+]])
32 void foo(int n) {
33 // CHECK: store i32 %[[N]], ptr %[[NADDR:[^,]+]]
34 // CHECK-LABEL: call void @a()
35 a();
36
37 // CHECK-LABEL: call void @b()
38 // CHECK: [[NARG:%[^ ]+]] = load i32, ptr %[[NADDR]]
39 // CHECK: [[BOOL:%[^ ]+]] = icmp ne i32 [[NARG]], 0
40 // CHECK: store i1 false
41 // CHECK: br i1 [[BOOL]], label %[[ONTRUE:[^,]+]], label %[[ONFALSE:[^,]+]]
42 //
43 // CHECK: [[ONTRUE]]:
44 // LIFETIME: @llvm.lifetime.start
45 // LIFETIME: store i1 true
46 // LIFETIME: call void @_ZN1XC
47 // CHECK: br label %[[END:[^,]+]]
48 //
49 // CHECK: [[ONFALSE]]:
50 // LIFETIME: @llvm.lifetime.start
51 // LIFETIME: store i1 true
52 // LIFETIME: call void @_ZN1YC
53 // CHECK: br label %[[END]]
54 //
55 // CHECK: [[END]]:
56 // CHECK: call void @c()
57 // LIFETIME: @llvm.lifetime.end
58 // LIFETIME: @llvm.lifetime.end
59 b(), (n ? X().p : Y().p), c();
60
61 // CHECK: call void @d()
62 d();
63 }