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

Side by Side 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 unified diff | Download patch
OLDNEW
1 //===- subzero/src/IceRegAlloc.cpp - Linear-scan implementation -----------===// 1 //===- subzero/src/IceRegAlloc.cpp - Linear-scan implementation -----------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 /// 9 ///
10 /// \file 10 /// \file
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 case RAK_Global: 243 case RAK_Global:
244 case RAK_Phi: 244 case RAK_Phi:
245 initForGlobal(); 245 initForGlobal();
246 break; 246 break;
247 case RAK_InfOnly: 247 case RAK_InfOnly:
248 initForInfOnly(); 248 initForInfOnly();
249 break; 249 break;
250 } 250 }
251 251
252 auto CompareRanges = [](const Variable *L, const Variable *R) { 252 auto CompareRanges = [](const Variable *L, const Variable *R) {
253 InstNumberT Lstart = L->getLiveRange().getStart(); 253 InstNumberT Lstart = L->getLiveRange().getStart();
254 InstNumberT Rstart = R->getLiveRange().getStart(); 254 InstNumberT Rstart = R->getLiveRange().getStart();
255 if (Lstart == Rstart) 255 if (Lstart == Rstart)
256 return L->getIndex() < R->getIndex(); 256 return L->getIndex() < R->getIndex();
257 return Lstart < Rstart; 257 return Lstart < Rstart;
258 }; 258 };
259 // Do a reverse sort so that erasing elements (from the end) is fast. 259 // Do a reverse sort so that erasing elements (from the end) is fast.
260 std::sort(Unhandled.rbegin(), Unhandled.rend(), CompareRanges); 260 std::sort(Unhandled.rbegin(), Unhandled.rend(), CompareRanges);
261 std::sort(UnhandledPrecolored.rbegin(), UnhandledPrecolored.rend(), 261 std::sort(UnhandledPrecolored.rbegin(), UnhandledPrecolored.rend(),
262 CompareRanges); 262 CompareRanges);
263 263
264 Handled.reserve(Unhandled.size()); 264 Handled.reserve(Unhandled.size());
265 Inactive.reserve(Unhandled.size()); 265 Inactive.reserve(Unhandled.size());
266 Active.reserve(Unhandled.size()); 266 Active.reserve(Unhandled.size());
267 } 267 }
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 for (Variable *I : Active) 769 for (Variable *I : Active)
770 Handled.push_back(I); 770 Handled.push_back(I);
771 Active.clear(); 771 Active.clear();
772 for (Variable *I : Inactive) 772 for (Variable *I : Inactive)
773 Handled.push_back(I); 773 Handled.push_back(I);
774 Inactive.clear(); 774 Inactive.clear();
775 dump(Func); 775 dump(Func);
776 776
777 llvm::SmallVector<int32_t, REGS_SIZE> Permutation(NumRegisters); 777 llvm::SmallVector<int32_t, REGS_SIZE> Permutation(NumRegisters);
778 if (Randomized) { 778 if (Randomized) {
779 // Create a random number generator for regalloc randomization.
780 // Use function's sequence and Kind value as the salt.
781 uint64_t Salt =
782 (Func->getSequenceNumber() << 1) ^ (Kind == RAK_Phi ? 0u : 1u);
779 Func->getTarget()->makeRandomRegisterPermutation( 783 Func->getTarget()->makeRandomRegisterPermutation(
780 Permutation, PreDefinedRegisters | ~RegMaskFull); 784 Permutation, PreDefinedRegisters | ~RegMaskFull, Salt);
781 } 785 }
782 786
783 // Finish up by assigning RegNumTmp->RegNum (or a random permutation 787 // Finish up by assigning RegNumTmp->RegNum (or a random permutation
784 // thereof) for each Variable. 788 // thereof) for each Variable.
785 for (Variable *Item : Handled) { 789 for (Variable *Item : Handled) {
786 int32_t RegNum = Item->getRegNumTmp(); 790 int32_t RegNum = Item->getRegNumTmp();
787 int32_t AssignedRegNum = RegNum; 791 int32_t AssignedRegNum = RegNum;
788 792
789 if (Randomized && Item->hasRegTmp() && !Item->hasReg()) { 793 if (Randomized && Item->hasRegTmp() && !Item->hasReg()) {
790 AssignedRegNum = Permutation[RegNum]; 794 AssignedRegNum = Permutation[RegNum];
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 Str << "\n"; 852 Str << "\n";
849 } 853 }
850 Str << "++++++ Inactive:\n"; 854 Str << "++++++ Inactive:\n";
851 for (const Variable *Item : Inactive) { 855 for (const Variable *Item : Inactive) {
852 dumpLiveRange(Item, Func); 856 dumpLiveRange(Item, Func);
853 Str << "\n"; 857 Str << "\n";
854 } 858 }
855 } 859 }
856 860
857 } // end of namespace Ice 861 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698