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