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

Side by Side Diff: src/IceTargetLoweringX8632.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: rebase to master 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
« no previous file with comments | « src/IceTargetLoweringMIPS32.cpp ('k') | src/IceTargetLoweringX8632Traits.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===// 1 //===- subzero/src/IceTargetLoweringX8632.cpp - x86-32 lowering -----------===//
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 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 Type Ty = T::Ty; 724 Type Ty = T::Ty;
725 SizeT Align = typeAlignInBytes(Ty); 725 SizeT Align = typeAlignInBytes(Ty);
726 ConstantList Pool = Ctx->getConstantPool(Ty); 726 ConstantList Pool = Ctx->getConstantPool(Ty);
727 727
728 Str << "\t.section\t.rodata.cst" << Align << ",\"aM\",@progbits," << Align 728 Str << "\t.section\t.rodata.cst" << Align << ",\"aM\",@progbits," << Align
729 << "\n"; 729 << "\n";
730 Str << "\t.align\t" << Align << "\n"; 730 Str << "\t.align\t" << Align << "\n";
731 731
732 // If reorder-pooled-constants option is set to true, we need to shuffle the 732 // If reorder-pooled-constants option is set to true, we need to shuffle the
733 // constant pool before emitting it. 733 // constant pool before emitting it.
734 if (Ctx->getFlags().shouldReorderPooledConstants()) 734 if (Ctx->getFlags().shouldReorderPooledConstants() && !Pool.empty()) {
735 RandomShuffle(Pool.begin(), Pool.end(), [Ctx](uint64_t N) { 735 // Use the constant's kind value as the salt for creating random number
736 return (uint32_t)Ctx->getRNG().next(N); 736 // generator.
737 }); 737 Operand::OperandKind K = (*Pool.begin())->getKind();
738
739 RandomNumberGenerator RNG(Ctx->getFlags().getRandomSeed(),
740 RPE_PooledConstantReordering, K);
741 RandomShuffle(Pool.begin(), Pool.end(),
742 [&RNG](uint64_t N) { return (uint32_t)RNG.next(N); });
743 }
738 744
739 for (Constant *C : Pool) { 745 for (Constant *C : Pool) {
740 if (!C->getShouldBePooled()) 746 if (!C->getShouldBePooled())
741 continue; 747 continue;
742 typename T::IceType *Const = llvm::cast<typename T::IceType>(C); 748 typename T::IceType *Const = llvm::cast<typename T::IceType>(C);
743 typename T::IceType::PrimType Value = Const->getValue(); 749 typename T::IceType::PrimType Value = Const->getValue();
744 // Use memcpy() to copy bits from Value into RawValue in a way 750 // Use memcpy() to copy bits from Value into RawValue in a way
745 // that avoids breaking strict-aliasing rules. 751 // that avoids breaking strict-aliasing rules.
746 typename T::PrimitiveIntType RawValue; 752 typename T::PrimitiveIntType RawValue;
747 memcpy(&RawValue, &Value, sizeof(Value)); 753 memcpy(&RawValue, &Value, sizeof(Value));
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 // entries in case the high-level table has extra entries. 948 // entries in case the high-level table has extra entries.
943 #define X(tag, sizeLog2, align, elts, elty, str) \ 949 #define X(tag, sizeLog2, align, elts, elty, str) \
944 static_assert(_table1_##tag == _table2_##tag, \ 950 static_assert(_table1_##tag == _table2_##tag, \
945 "Inconsistency between ICETYPEX8632_TABLE and ICETYPE_TABLE"); 951 "Inconsistency between ICETYPEX8632_TABLE and ICETYPE_TABLE");
946 ICETYPE_TABLE 952 ICETYPE_TABLE
947 #undef X 953 #undef X
948 } // end of namespace dummy3 954 } // end of namespace dummy3
949 } // end of anonymous namespace 955 } // end of anonymous namespace
950 956
951 } // end of namespace Ice 957 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceTargetLoweringMIPS32.cpp ('k') | src/IceTargetLoweringX8632Traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698