summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPuyan Lotfi <puyan@puyan.org>2019-06-11 00:00:25 +0000
committerPuyan Lotfi <puyan@puyan.org>2019-06-11 00:00:25 +0000
commit4d89462a1cc2f2bb101989e87b0ca59ff99e7490 (patch)
tree18724250b0f29ad294993da6e8420e40ef186d39
parentcd0bc478366d4926f852cf881cf84b296714f391 (diff)
downloadbcm5719-llvm-4d89462a1cc2f2bb101989e87b0ca59ff99e7490.tar.gz
bcm5719-llvm-4d89462a1cc2f2bb101989e87b0ca59ff99e7490.zip
[MIR-Canon] Fixing non-determinism that was breaking bots (NFC).
An earlier fix of a subtle iterator invalidation bug had uncovered a nondeterminism that was present in the MultiUsers bag. Problem was that MultiUsers was being looked up using pointers. This patch is an NFC change that numbers each multiuser and processes each in numbered order. This fixes the test failure on netbsd and will likely fix the green-dragon bot too. llvm-svn: 363012
-rw-r--r--llvm/lib/CodeGen/MIRCanonicalizerPass.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MIRCanonicalizerPass.cpp b/llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
index c7d1131d7b8..f49bc854e23 100644
--- a/llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
+++ b/llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
@@ -180,6 +180,8 @@ static bool rescheduleCanonically(unsigned &PseudoIdempotentInstCount,
}
std::map<MachineInstr *, std::vector<MachineInstr *>> MultiUsers;
+ std::map<unsigned, MachineInstr *> MultiUserLookup;
+ unsigned UseToBringDefCloserToCount = 0;
std::vector<MachineInstr *> PseudoIdempotentInstructions;
std::vector<unsigned> PhysRegDefs;
for (auto *II : Instructions) {
@@ -255,6 +257,7 @@ static bool rescheduleCanonically(unsigned &PseudoIdempotentInstCount,
if (Delta < Distance) {
Distance = Delta;
UseToBringDefCloserTo = UseInst;
+ MultiUserLookup[UseToBringDefCloserToCount++] = UseToBringDefCloserTo;
}
}
@@ -294,11 +297,11 @@ static bool rescheduleCanonically(unsigned &PseudoIdempotentInstCount,
}
// Sort the defs for users of multiple defs lexographically.
- for (const auto &E : MultiUsers) {
+ for (const auto &E : MultiUserLookup) {
auto UseI =
std::find_if(MBB->instr_begin(), MBB->instr_end(),
- [&](MachineInstr &MI) -> bool { return &MI == E.first; });
+ [&](MachineInstr &MI) -> bool { return &MI == E.second; });
if (UseI == MBB->instr_end())
continue;
@@ -306,7 +309,8 @@ static bool rescheduleCanonically(unsigned &PseudoIdempotentInstCount,
LLVM_DEBUG(
dbgs() << "Rescheduling Multi-Use Instructions Lexographically.";);
Changed |= rescheduleLexographically(
- E.second, MBB, [&]() -> MachineBasicBlock::iterator { return UseI; });
+ MultiUsers[E.second], MBB,
+ [&]() -> MachineBasicBlock::iterator { return UseI; });
}
PseudoIdempotentInstCount = PseudoIdempotentInstructions.size();
OpenPOWER on IntegriCloud