summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2016-07-28 22:50:48 +0000
committerVitaly Buka <vitalybuka@google.com>2016-07-28 22:50:48 +0000
commitf0500b6ae526fef8238f4f6017ac9da2f5c3f756 (patch)
treeb83db977507c80597568dd337804f3845ced274c /llvm/lib/Transforms
parent36457938725a34da13936a0e1eead7cc2147b0a2 (diff)
downloadbcm5719-llvm-f0500b6ae526fef8238f4f6017ac9da2f5c3f756.tar.gz
bcm5719-llvm-f0500b6ae526fef8238f4f6017ac9da2f5c3f756.zip
Do not remove empty lifetime.start/lifetime.end ranges
Summary: Asan stack-use-after-scope check should poison alloca even if there is no access between start and end. This is possible for code like this: for (int i = 0; i < 3; i++) { int x; p = &x; } "Loop Invariant Code Motion" will move "p = &x;" out of the loop, making start/end range empty. PR27453 Reviewers: eugenis Differential Revision: https://reviews.llvm.org/D22842 llvm-svn: 277068
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 5446ce0f04f..52c377786bf 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -30,8 +30,6 @@ using namespace PatternMatch;
STATISTIC(NumSimplified, "Number of library calls simplified");
-extern cl::opt<bool> ClUseAfterScope;
-
/// Return the specified type promoted as it would be to pass though a va_arg
/// area.
static Type *getPromotedType(Type *Ty) {
@@ -2244,18 +2242,16 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
return eraseInstFromFunction(CI);
break;
}
- case Intrinsic::lifetime_start: {
- const Function *func = II->getFunction();
- // Asan needs to poison memory to detect invalid access possible even for
- // empty lifetime range.
- if (func && func->hasFnAttribute(Attribute::SanitizeAddress))
+ case Intrinsic::lifetime_start:
+ // Asan needs to poison memory to detect invalid access which is possible
+ // even for empty lifetime range.
+ if (II->getFunction()->hasFnAttribute(Attribute::SanitizeAddress))
break;
if (removeTriviallyEmptyRange(*II, Intrinsic::lifetime_start,
Intrinsic::lifetime_end, *this))
return nullptr;
break;
- }
case Intrinsic::assume: {
Value *IIOperand = II->getArgOperand(0);
// Remove an assume if it is immediately followed by an identical assume.
@@ -2486,6 +2482,7 @@ static IntrinsicInst *findInitTrampoline(Value *Callee) {
/// Improvements for call and invoke instructions.
Instruction *InstCombiner::visitCallSite(CallSite CS) {
+
if (isAllocLikeFn(CS.getInstruction(), TLI))
return visitAllocSite(*CS.getInstruction());
OpenPOWER on IntegriCloud