summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/LoopAccessAnalysis.cpp
diff options
context:
space:
mode:
authorAdam Nemet <anemet@apple.com>2015-08-21 23:19:57 +0000
committerAdam Nemet <anemet@apple.com>2015-08-21 23:19:57 +0000
commit4e533ef7a95faca92757acccd6f92ffa97783b4b (patch)
treeda4f6cf91234c9e2bd2fc4258b37b08417b97b6c /llvm/lib/Analysis/LoopAccessAnalysis.cpp
parent552a62fabc00e80a2ba5825910f6b0efc7037a2e (diff)
downloadbcm5719-llvm-4e533ef7a95faca92757acccd6f92ffa97783b4b.tar.gz
bcm5719-llvm-4e533ef7a95faca92757acccd6f92ffa97783b4b.zip
[LAA] Hold bounds via ValueHandles during SCEV expansion
SCEV expansion can invalidate previously expanded values. For example in SCEVExpander::ReuseOrCreateCast, if we already have the requested cast value but it's not at the desired location, a new cast is inserted and the old cast will be invalidated. Therefore, when expanding the bounds for the pointers, a later entry can invalidate the IR value for an earlier one. The fix is to store a value handle rather than the value itself. The newly added test has a more detailed description of how the bug triggers. This bug can have a negative but potentially highly variable performance impact in Loop Distribution. Because one of the bound values was invalidated and is an undef expression now, InstCombine is free to transform the array overlap check: Start0 <= End1 && Start1 <= End0 into: Start0 <= End1 So depending on the runtime location of the arrays, we would detect a conflict and fall back on the original loop of the versioned loop. Also tested compile time with SPEC2006 LTO bc files. llvm-svn: 245760
Diffstat (limited to 'llvm/lib/Analysis/LoopAccessAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/LoopAccessAnalysis.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 41499df43cc..87dd8d47a65 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -1593,10 +1593,13 @@ static Instruction *getFirstInst(Instruction *FirstInst, Value *V,
return nullptr;
}
-/// \brief IR Values for the lower and upper bounds of a pointer evolution.
+/// \brief IR Values for the lower and upper bounds of a pointer evolution. We
+/// need to use value-handles because SCEV expansion can invalidate previously
+/// expanded values. Thus expansion of a pointer can invalidate the bounds for
+/// a previous one.
struct PointerBounds {
- Value *Start;
- Value *End;
+ TrackingVH<Value> Start;
+ TrackingVH<Value> End;
};
/// \brief Expand code for the lower and upper bound of the pointer group \p CG
OpenPOWER on IntegriCloud