Chromium Code Reviews| Index: src/IceRegAlloc.cpp |
| diff --git a/src/IceRegAlloc.cpp b/src/IceRegAlloc.cpp |
| index 0d9afba44d55c72f68d4bab6ac184380781bf21b..cb9dc679557a24e4bcc7f0cf675727d6439222c1 100644 |
| --- a/src/IceRegAlloc.cpp |
| +++ b/src/IceRegAlloc.cpp |
| @@ -250,11 +250,11 @@ void LinearScan::init(RegAllocKind Kind) { |
| } |
| auto CompareRanges = [](const Variable *L, const Variable *R) { |
| - InstNumberT Lstart = L->getLiveRange().getStart(); |
| - InstNumberT Rstart = R->getLiveRange().getStart(); |
| - if (Lstart == Rstart) |
| - return L->getIndex() < R->getIndex(); |
| - return Lstart < Rstart; |
| + InstNumberT Lstart = L->getLiveRange().getStart(); |
| + InstNumberT Rstart = R->getLiveRange().getStart(); |
| + if (Lstart == Rstart) |
| + return L->getIndex() < R->getIndex(); |
| + return Lstart < Rstart; |
| }; |
| // Do a reverse sort so that erasing elements (from the end) is fast. |
| std::sort(Unhandled.rbegin(), Unhandled.rend(), CompareRanges); |
| @@ -776,8 +776,15 @@ void LinearScan::scan(const llvm::SmallBitVector &RegMaskFull, |
| llvm::SmallVector<int32_t, REGS_SIZE> Permutation(NumRegisters); |
| if (Randomized) { |
| + // Create a random number generator for regalloc randomization. Merge |
| + // function's sequence and Kind value as the Salt. Because regalloc() |
|
Jim Stichnoth
2015/08/20 20:01:33
regAlloc
|
| + // are called twice under O2, the second time with RAK_Phi, we check |
|
Jim Stichnoth
2015/08/20 20:01:33
is called
|
| + // Kind == RAK_Phi to determine the least bit to make sure the Salt is |
|
Jim Stichnoth
2015/08/20 20:01:33
I would say "lowest-order" instead of "least".
|
| + // different. |
| + uint64_t Salt = |
| + (Func->getSequenceNumber() << 1) ^ (Kind == RAK_Phi ? 0u : 1u); |
| Func->getTarget()->makeRandomRegisterPermutation( |
| - Permutation, PreDefinedRegisters | ~RegMaskFull); |
| + Permutation, PreDefinedRegisters | ~RegMaskFull, Salt); |
| } |
| // Finish up by assigning RegNumTmp->RegNum (or a random permutation |