Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Unified Diff: src/IceRegAlloc.cpp

Issue 1300993002: Use separate random number generator for each randomization pass (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Minor change in GlobalContext::getJumpTables(), make jump tables in deterministic order even pooled… Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/IceRegAlloc.cpp
diff --git a/src/IceRegAlloc.cpp b/src/IceRegAlloc.cpp
index 0d9afba44d55c72f68d4bab6ac184380781bf21b..8d28475022619c6e5e1bbab013fc8bcff5ece73e 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,12 @@ 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.
+ // Use function's sequence and Kind value as the salt.
+ 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

Powered by Google App Engine
This is Rietveld 408576698