diff options
author | Arnaud A. de Grandmaison <arnaud.degrandmaison@arm.com> | 2014-10-08 14:04:26 +0000 |
---|---|---|
committer | Arnaud A. de Grandmaison <arnaud.degrandmaison@arm.com> | 2014-10-08 14:04:26 +0000 |
commit | e69ec55cda95e5f6aa71ed5c0a38dbb6504a23bb (patch) | |
tree | fd01977e1797e32dda5bb07ee674634b9f38224d /clang/lib/CodeGen/CGDecl.cpp | |
parent | 4a5bb772c362afeb3586b84edc3c2d0eeae31327 (diff) | |
download | llvm-e69ec55cda95e5f6aa71ed5c0a38dbb6504a23bb.zip llvm-e69ec55cda95e5f6aa71ed5c0a38dbb6504a23bb.tar.gz llvm-e69ec55cda95e5f6aa71ed5c0a38dbb6504a23bb.tar.bz2 |
Revert "Remove threshold on object size for inserting lifetime begin / end"
Revert this patch while I investigate some sanitizer failures off-line.
llvm-svn: 219307
Diffstat (limited to 'clang/lib/CodeGen/CGDecl.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGDecl.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index f943faf..24575ce 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -825,6 +825,19 @@ static bool shouldUseMemSetPlusStoresToInitialize(llvm::Constant *Init, canEmitInitWithFewStoresAfterMemset(Init, StoreBudget); } +/// Should we use the LLVM lifetime intrinsics for the given local variable? +static bool shouldUseLifetimeMarkers(CodeGenFunction &CGF, uint64_t Size) { + // For now, only in optimized builds. + if (CGF.CGM.getCodeGenOpts().OptimizationLevel == 0) + return false; + + // Limit the size of marked objects to 32 bytes. We don't want to increase + // compile time by marking tiny objects. + unsigned SizeThreshold = 32; + + return Size > SizeThreshold; +} + /// EmitAutoVarDecl - Emit code and set up an entry in LocalDeclMap for a /// variable declaration with auto, register, or no storage class specifier. /// These turn into simple stack objects, or GlobalValues depending on target. @@ -839,12 +852,7 @@ void CodeGenFunction::EmitAutoVarDecl(const VarDecl &D) { /// otherwise llvm::Value *CodeGenFunction::EmitLifetimeStart(uint64_t Size, llvm::Value *Addr) { - // For now, only use the markers in optimized builds - if (CGM.getCodeGenOpts().OptimizationLevel == 0) - return nullptr; - - // Zero-sized objects do not need lifetime markers - if (Size == 0) + if (!shouldUseLifetimeMarkers(*this, Size)) return nullptr; llvm::Value *SizeV = llvm::ConstantInt::get(Int64Ty, Size); @@ -955,10 +963,11 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) { // Emit a lifetime intrinsic if meaningful. There's no point // in doing this if we don't have a valid insertion point (?). uint64_t size = CGM.getDataLayout().getTypeAllocSize(LTy); - if (HaveInsertPoint()) - emission.SizeForLifetimeMarkers = EmitLifetimeStart(size, Alloc); - else + if (HaveInsertPoint() && EmitLifetimeStart(size, Alloc)) { + emission.SizeForLifetimeMarkers = llvm::ConstantInt::get(Int64Ty, size); + } else { assert(!emission.useLifetimeMarkers()); + } } } else { EnsureInsertPoint(); |