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

Unified Diff: src/IceTargetLowering.cpp

Issue 463563006: Subzero: Randomly insert nops. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Remove redundancy and fix formatting. Created 6 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
Index: src/IceTargetLowering.cpp
diff --git a/src/IceTargetLowering.cpp b/src/IceTargetLowering.cpp
index 0034de5f7ca3e2340eb15e52f23530dfafc8ca56..5874e79bceb7c4407c3eeff421c04de0ac5c0e6c 100644
--- a/src/IceTargetLowering.cpp
+++ b/src/IceTargetLowering.cpp
@@ -22,8 +22,20 @@
#include "IceTargetLowering.h"
#include "IceTargetLoweringX8632.h"
+#include "llvm/Support/CommandLine.h"
+
namespace Ice {
+namespace {
+namespace cl = llvm::cl;
+cl::opt<bool> DoNopInsertion("insert-nops", cl::desc("Randomly insert NOPs"),
+ cl::init(false));
+cl::opt<int> NopProbability("nop-probability",
+ cl::desc("Nop insertion probability"),
jvoung (off chromium) 2014/08/14 15:17:17 A default of "10" should be a strong hint at the u
wala 2014/08/14 23:29:50 Done.
+ cl::init(10));
+} // end anonymous namespace
Jim Stichnoth 2014/08/14 01:20:10 end of anonymous namespace
wala 2014/08/14 23:29:50 Done.
+
+
void LoweringContext::init(CfgNode *N) {
Node = N;
Begin = getNode()->getInsts().begin();
@@ -90,6 +102,16 @@ void TargetLowering::doAddressOpt() {
Context.advanceNext();
}
+bool TargetLowering::shouldDoNopInsertion() const {
+ return DoNopInsertion;
+}
+
+void TargetLowering::doNopInsertion() {
+ randomlyInsertNop(NopProbability / 100.0);
+ Context.advanceCur();
+ Context.advanceNext();
+}
+
// Lowers a single instruction according to the information in
// Context, by checking the Context.Cur instruction kind and calling
// the appropriate lowering method. The lowering method should insert

Powered by Google App Engine
This is Rietveld 408576698