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

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: Assign default value of ConstantBlindingCookie in its declaration 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/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()) {
735 RandomShuffle(Pool.begin(), Pool.end(), [Ctx](uint64_t N) { 735 if (!Pool.empty()) {
Jim Stichnoth 2015/08/19 19:03:04 can probably combine this condition with the above
qining 2015/08/19 23:25:49 Done.
736 return (uint32_t)Ctx->getRNG().next(N); 736 // Use the constant's kind value as the salt for creating random number
737 }); 737 // generator.
738 Operand::OperandKind K = (*Pool.begin())->getKind();
739
740 RandomNumberGenerator RNG(Ctx->getFlags().getRandomSeed(),
741 RS_PooledConstantReordering, K);
742 RandomShuffle(Pool.begin(), Pool.end(),
743 [&RNG](uint64_t N) { return (uint32_t)RNG.next(N); });
744 }
745 }
738 746
739 for (Constant *C : Pool) { 747 for (Constant *C : Pool) {
740 if (!C->getShouldBePooled()) 748 if (!C->getShouldBePooled())
741 continue; 749 continue;
742 typename T::IceType *Const = llvm::cast<typename T::IceType>(C); 750 typename T::IceType *Const = llvm::cast<typename T::IceType>(C);
743 typename T::IceType::PrimType Value = Const->getValue(); 751 typename T::IceType::PrimType Value = Const->getValue();
744 // Use memcpy() to copy bits from Value into RawValue in a way 752 // Use memcpy() to copy bits from Value into RawValue in a way
745 // that avoids breaking strict-aliasing rules. 753 // that avoids breaking strict-aliasing rules.
746 typename T::PrimitiveIntType RawValue; 754 typename T::PrimitiveIntType RawValue;
747 memcpy(&RawValue, &Value, sizeof(Value)); 755 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. 950 // entries in case the high-level table has extra entries.
943 #define X(tag, sizeLog2, align, elts, elty, str) \ 951 #define X(tag, sizeLog2, align, elts, elty, str) \
944 static_assert(_table1_##tag == _table2_##tag, \ 952 static_assert(_table1_##tag == _table2_##tag, \
945 "Inconsistency between ICETYPEX8632_TABLE and ICETYPE_TABLE"); 953 "Inconsistency between ICETYPEX8632_TABLE and ICETYPE_TABLE");
946 ICETYPE_TABLE 954 ICETYPE_TABLE
947 #undef X 955 #undef X
948 } // end of namespace dummy3 956 } // end of namespace dummy3
949 } // end of anonymous namespace 957 } // end of anonymous namespace
950 958
951 } // end of namespace Ice 959 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698