summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSilviu Baranga <silviu.baranga@arm.com>2015-07-09 15:18:25 +0000
committerSilviu Baranga <silviu.baranga@arm.com>2015-07-09 15:18:25 +0000
commitce3877fc8c9b1a439be39e8807ca97aedf0651eb (patch)
treef060f342e8f6e001f0bbacb1b83552f5552d0512 /llvm/lib
parentb870e9ca935fa7d2c8b405ee6a6e15eee47405fd (diff)
downloadbcm5719-llvm-ce3877fc8c9b1a439be39e8807ca97aedf0651eb.tar.gz
bcm5719-llvm-ce3877fc8c9b1a439be39e8807ca97aedf0651eb.zip
Don't rely on the DepCands iteration order when constructing checking pointer groups
Summary: The checking pointer group construction algorithm relied on the iteration on DepCands. We would need the same leaders across runs and the same iteration order over the underlying std::set for determinism. This changes the algorithm to process the pointers in the order in which they were added to the runtime check, which is deterministic. We need to update the tests, since the order in which pointers appear has changed. No new tests were added, since it is impossible to test for non-determinism. Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D11064 llvm-svn: 241809
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/LoopAccessAnalysis.cpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 35431f62a6c..cd30915ac0a 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -222,18 +222,40 @@ void LoopAccessInfo::RuntimePointerCheck::groupChecks(
for (unsigned Pointer = 0; Pointer < Pointers.size(); ++Pointer)
PositionMap[Pointers[Pointer]] = Pointer;
+ // We need to keep track of what pointers we've already seen so we
+ // don't process them twice.
+ SmallSet<unsigned, 2> Seen;
+
// Go through all equivalence classes, get the the "pointer check groups"
- // and add them to the overall solution.
- for (auto DI = DepCands.begin(), DE = DepCands.end(); DI != DE; ++DI) {
- if (!DI->isLeader())
+ // and add them to the overall solution. We use the order in which accesses
+ // appear in 'Pointers' to enforce determinism.
+ for (unsigned I = 0; I < Pointers.size(); ++I) {
+ // We've seen this pointer before, and therefore already processed
+ // its equivalence class.
+ if (Seen.count(I))
continue;
+ MemoryDepChecker::MemAccessInfo Access(Pointers[I], IsWritePtr[I]);
+
SmallVector<CheckingPtrGroup, 2> Groups;
+ auto LeaderI = DepCands.findValue(DepCands.getLeaderValue(Access));
+
+ SmallVector<unsigned, 2> MemberIndices;
- for (auto MI = DepCands.member_begin(DI), ME = DepCands.member_end();
+ // Get all indeces of the members of this equivalence class and sort them.
+ // This will allow us to process all accesses in the order in which they
+ // were added to the RuntimePointerCheck.
+ for (auto MI = DepCands.member_begin(LeaderI), ME = DepCands.member_end();
MI != ME; ++MI) {
unsigned Pointer = PositionMap[MI->getPointer()];
+ MemberIndices.push_back(Pointer);
+ }
+ std::sort(MemberIndices.begin(), MemberIndices.end());
+
+ for (unsigned Pointer : MemberIndices) {
bool Merged = false;
+ // Mark this pointer as seen.
+ Seen.insert(Pointer);
// Go through all the existing sets and see if we can find one
// which can include this pointer.
OpenPOWER on IntegriCloud