diff options
author | Reid Kleckner <reid@kleckner.net> | 2015-04-23 18:07:13 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2015-04-23 18:07:13 +0000 |
commit | 1ef49218b31145c6b0d1d1095a4be2103c93e4ce (patch) | |
tree | 78ee38cfeb3b8d9eff2015566610174dcc75dbef /clang | |
parent | 6489d7b9490a0099ad1b0e5ba143591b4de71db3 (diff) | |
download | bcm5719-llvm-1ef49218b31145c6b0d1d1095a4be2103c93e4ce.tar.gz bcm5719-llvm-1ef49218b31145c6b0d1d1095a4be2103c93e4ce.zip |
Don't emit lifetime markers when msan is enabled
In r235553, Clang started emitting lifetime markers more often. This
caused false negative in MSan, because MSan only poisons all allocas
once at function entry. Eventually, MSan should poison allocas at
lifetime start and probably also lifetime end, but until then, let's not
emit markers that aren't going to be useful.
llvm-svn: 235613
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/CodeGen/CGDecl.cpp | 5 | ||||
-rw-r--r-- | clang/test/CodeGen/cleanup-destslot-simple.c | 10 |
2 files changed, 12 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 29c63151466..874cf693809 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -856,6 +856,11 @@ llvm::Value *CodeGenFunction::EmitLifetimeStart(uint64_t Size, if (CGM.getCodeGenOpts().OptimizationLevel == 0) return nullptr; + // Disable lifetime markers in msan builds. + // FIXME: Remove this when msan works with lifetime markers. + if (getLangOpts().Sanitize.has(SanitizerKind::Memory)) + return nullptr; + llvm::Value *SizeV = llvm::ConstantInt::get(Int64Ty, Size); llvm::Value *Args[] = { SizeV, diff --git a/clang/test/CodeGen/cleanup-destslot-simple.c b/clang/test/CodeGen/cleanup-destslot-simple.c index 0ee52e1d9fa..bae97c81cbb 100644 --- a/clang/test/CodeGen/cleanup-destslot-simple.c +++ b/clang/test/CodeGen/cleanup-destslot-simple.c @@ -1,4 +1,8 @@ -// RUN: %clang_cc1 -O1 -triple x86_64-none-linux-gnu -emit-llvm -gline-tables-only %s -o - | FileCheck %s +// RUN: %clang_cc1 -O1 -triple x86_64-none-linux-gnu -emit-llvm -gline-tables-only %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=LIFETIME + +// We shouldn't have markers at -O0 or with msan. +// RUN: %clang_cc1 -O0 -triple x86_64-none-linux-gnu -emit-llvm -gline-tables-only %s -o - | FileCheck %s --check-prefix=CHECK +// RUN: %clang_cc1 -O1 -triple x86_64-none-linux-gnu -emit-llvm -gline-tables-only %s -o - -fsanitize=memory | FileCheck %s --check-prefix=CHECK // There is no exception to handle here, lifetime.end is not a destructor, // so there is no need have cleanup dest slot related code @@ -9,7 +13,7 @@ int test() { return *p; // CHECK: [[X:%.*]] = alloca i32 // CHECK: [[P:%.*]] = alloca i32* -// CHECK: call void @llvm.lifetime.start(i64 4, i8* %{{.*}}) -// CHECK: call void @llvm.lifetime.start(i64 8, i8* %{{.*}}) +// LIFETIME: call void @llvm.lifetime.start(i64 4, i8* %{{.*}}) +// LIFETIME: call void @llvm.lifetime.start(i64 8, i8* %{{.*}}) // CHECK-NOT: store i32 %{{.*}}, i32* %cleanup.dest.slot } |