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

Unified Diff: src/IceCfg.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceCfg.h ('k') | src/IceCfgNode.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceCfg.cpp
diff --git a/src/IceCfg.cpp b/src/IceCfg.cpp
index 218ecd9017197485c2e0a2401daf0700b655e268..cc6d07c0e1bbba9c06406ac7e126e8ac6a2d7a66 100644
--- a/src/IceCfg.cpp
+++ b/src/IceCfg.cpp
@@ -43,6 +43,16 @@ Cfg::Cfg(GlobalContext *Ctx, uint32_t SequenceNumber)
VMetadata(new VariablesMetadata(this)),
TargetAssembler(TargetLowering::createAssembler(
Ctx->getFlags().getTargetArch(), this)) {
+ assert(!Ctx->isIRGenerationDisabled() &&
+ "Attempt to build cfg when IR generation disabled");
+ if (Ctx->getFlags().getRandomizeAndPoolImmediatesOption() == RPI_Randomize) {
+ // If -randomize-pool-immediates=randomize, create a random number generator
+ // to generate a cookie for constant blinding.
+ RandomNumberGenerator RNG(Ctx->getFlags().getRandomSeed(),
+ RPE_ConstantBlinding, SequenceNumber);
+ ConstantBlindingCookie =
+ (uint32_t)RNG.next((uint64_t)std::numeric_limits<uint32_t>::max + 1);
+ }
}
Cfg::~Cfg() { assert(ICE_TLS_GET_FIELD(CurrentCfg) == nullptr); }
@@ -396,9 +406,11 @@ void Cfg::shuffleNodes() {
NodeList ReversedReachable;
NodeList Unreachable;
llvm::BitVector ToVisit(Nodes.size(), true);
+ // Create Random number generator for function reordering
+ RandomNumberGenerator RNG(Ctx->getFlags().getRandomSeed(),
+ RPE_BasicBlockReordering, SequenceNumber);
// Traverse from entry node.
- getRandomPostOrder(getEntryNode(), ToVisit, ReversedReachable,
- &Ctx->getRNG());
+ getRandomPostOrder(getEntryNode(), ToVisit, ReversedReachable, &RNG);
// Collect the unreachable nodes.
for (CfgNode *Node : Nodes)
if (ToVisit[Node->getIndex()])
@@ -431,8 +443,10 @@ void Cfg::doNopInsertion() {
if (!Ctx->getFlags().shouldDoNopInsertion())
return;
TimerMarker T(TimerStack::TT_doNopInsertion, this);
+ RandomNumberGenerator RNG(Ctx->getFlags().getRandomSeed(), RPE_NopInsertion,
+ SequenceNumber);
for (CfgNode *Node : Nodes)
- Node->doNopInsertion();
+ Node->doNopInsertion(RNG);
}
void Cfg::genCode() {
« no previous file with comments | « src/IceCfg.h ('k') | src/IceCfgNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698