diff options
author | Hal Finkel <hfinkel@anl.gov> | 2014-12-04 17:45:19 +0000 |
---|---|---|
committer | Hal Finkel <hfinkel@anl.gov> | 2014-12-04 17:45:19 +0000 |
commit | aa19bafc9c4df6d1a733b31147a14bd692bfacb5 (patch) | |
tree | 5c9658ff681c4fb6a0f786f2d8e83e61caca26e3 /llvm/lib/Analysis/InstructionSimplify.cpp | |
parent | eafafa37bcc43f981b8ba9c9398422f694ee1a8e (diff) | |
download | bcm5719-llvm-aa19bafc9c4df6d1a733b31147a14bd692bfacb5.tar.gz bcm5719-llvm-aa19bafc9c4df6d1a733b31147a14bd692bfacb5.zip |
Revert "r223364 - Revert r223347 which has caused crashes on bootstrap bots."
Reapply r223347, with a fix to not crash on uninserted instructions (or more
precisely, instructions in uninserted blocks). bugpoint was able to reduce the
test case somewhat, but it is still somewhat large (and relies on setting
things up to be simplified during inlining), so I've not included it here.
Nevertheless, it is clear what is going on and why.
Original commit message:
Restrict somewhat the memory-allocation pointer cmp opt from r223093
Based on review comments from Richard Smith, restrict this optimization from
applying to globals that might resolve lazily to other dynamically-loaded
modules, and also from dynamic allocas (which might be transformed into malloc
calls). In short, take extra care that the compared-to pointer is really
simultaneously live with the memory allocation.
llvm-svn: 223371
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 85ebf694e69..45290fdcc00 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -2026,12 +2026,23 @@ static Constant *computePointerICmp(const DataLayout *DL, }; // Is the set of underlying objects all things which must be disjoint from - // noalias calls. + // noalias calls. For allocas, we consider only static ones (dynamic + // allocas might be transformed into calls to malloc not simultaneously + // live with the compared-to allocation). For globals, we exclude symbols + // that might be resolve lazily to symbols in another dynamically-loaded + // library (and, thus, could be malloc'ed by the implementation). auto IsAllocDisjoint = [](SmallVectorImpl<Value *> &Objects) { return std::all_of(Objects.begin(), Objects.end(), [](Value *V){ - if (isa<AllocaInst>(V) || isa<GlobalValue>(V)) - return true; + if (const AllocaInst *AI = dyn_cast<AllocaInst>(V)) + return AI->getParent() && AI->getParent()->getParent() && + AI->isStaticAlloca(); + if (const GlobalValue *GV = dyn_cast<GlobalValue>(V)) + return (GV->hasLocalLinkage() || + GV->hasHiddenVisibility() || + GV->hasProtectedVisibility() || + GV->hasUnnamedAddr()) && + !GV->isThreadLocal(); if (const Argument *A = dyn_cast<Argument>(V)) return A->hasByValAttr(); return false; |