Subzero: Randomly insert nops.
Adds command line options -nop-insertion, -nop-insertion-probability=X, and -max-nops-per-instruction=X.
BUG=none
R=jvoung@chromium.org, stichnot@chromium.org
Review URL: https://codereview.chromium.org/463563006
diff --git a/src/IceCfgNode.cpp b/src/IceCfgNode.cpp
index 22915b2..696a2f0 100644
--- a/src/IceCfgNode.cpp
+++ b/src/IceCfgNode.cpp
@@ -191,6 +191,24 @@
}
}
+void CfgNode::doNopInsertion() {
+ TargetLowering *Target = Func->getTarget();
+ LoweringContext &Context = Target->getContext();
+ Context.init(this);
+ while (!Context.atEnd()) {
+ Target->doNopInsertion();
+ // Ensure Cur=Next, so that the nops are inserted before the current
+ // instruction rather than after.
+ Context.advanceNext();
+ Context.advanceCur();
+ }
+ // Insert before all instructions.
+ Context.setInsertPoint(getInsts().begin());
+ Context.advanceNext();
+ Context.advanceCur();
+ Target->doNopInsertion();
+}
+
// Drives the target lowering. Passes the current instruction and the
// next non-deleted instruction for target lowering.
void CfgNode::genCode() {