Clang Project

clang_source_code/test/CodeGen/cleanup-destslot-simple.c
1// RUN: %clang_cc1 -O1 -triple x86_64-none-linux-gnu -emit-llvm -debug-info-kind=line-tables-only %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=LIFETIME
2
3// We shouldn't have markers at -O0 or with msan.
4// RUN: %clang_cc1 -O0 -triple x86_64-none-linux-gnu -emit-llvm -debug-info-kind=line-tables-only %s -o - | FileCheck %s
5// RUN: %clang_cc1 -O1 -triple x86_64-none-linux-gnu -emit-llvm -debug-info-kind=line-tables-only %s -o - -fsanitize=memory | FileCheck %s
6// RUN: %clang_cc1 -O1 -triple x86_64-none-linux-gnu -emit-llvm -debug-info-kind=line-tables-only %s -o - -fsanitize=kernel-memory | FileCheck %s
7
8// There is no exception to handle here, lifetime.end is not a destructor,
9// so there is no need have cleanup dest slot related code
10// CHECK-LABEL: define i32 @test
11int test() {
12  int x = 3;
13  int *volatile p = &x;
14  return *p;
15// CHECK: [[X:%.*]] = alloca i32
16// CHECK: [[P:%.*]] = alloca i32*
17// LIFETIME: call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %{{.*}}){{( #[0-9]+)?}}, !dbg
18// LIFETIME: call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %{{.*}}){{( #[0-9]+)?}}, !dbg
19// CHECK-NOT: store i32 %{{.*}}, i32* %cleanup.dest.slot
20// LIFETIME: call void @llvm.lifetime.end.p0i8(i64 8, {{.*}}){{( #[0-9]+)?}}, !dbg
21// LIFETIME: call void @llvm.lifetime.end.p0i8(i64 4, {{.*}}){{( #[0-9]+)?}}, !dbg
22}
23