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

Unified Diff: src/IceASanInstrumentation.cpp

Issue 2067403002: Instrumented load and store with dummy calls to __asan_check(). (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Improved tests Created 4 years, 6 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/IceASanInstrumentation.h ('k') | src/IceCompileServer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceASanInstrumentation.cpp
diff --git a/src/IceASanInstrumentation.cpp b/src/IceASanInstrumentation.cpp
index 1cda875a3cd71922efda515f0ad72ee94963b759..589bf1a04f3090c3db04824db05317a8e6a8e145 100644
--- a/src/IceASanInstrumentation.cpp
+++ b/src/IceASanInstrumentation.cpp
@@ -18,6 +18,8 @@
#include "IceCfgNode.h"
#include "IceGlobalInits.h"
#include "IceInst.h"
+#include "IceTargetLowering.h"
+#include "IceTypes.h"
#include <sstream>
@@ -111,13 +113,43 @@ ASanInstrumentation::createRz(VariableDeclarationList *List,
return Rz;
}
+void ASanInstrumentation::instrumentLoad(LoweringContext &Context,
+ const InstLoad *Inst) {
+ instrumentAccess(Context, Inst->getSourceAddress(),
+ typeWidthInBytes(Inst->getDest()->getType()));
+}
+
+void ASanInstrumentation::instrumentStore(LoweringContext &Context,
+ const InstStore *Inst) {
+ instrumentAccess(Context, Inst->getAddr(),
+ typeWidthInBytes(Inst->getData()->getType()));
+}
+
+// TODO(tlively): Take size of access into account as well
+void ASanInstrumentation::instrumentAccess(LoweringContext &Context,
+ Operand *Op, SizeT Size) {
+ Constant *AccessCheck =
+ Ctx->getConstantExternSym(Ctx->getGlobalString("__asan_check"));
+ constexpr SizeT NumArgs = 2;
+ constexpr Variable *Void = nullptr;
+ constexpr bool NoTailCall = false;
+ auto *Call = InstCall::create(Context.getNode()->getCfg(), NumArgs, Void,
+ AccessCheck, NoTailCall);
+ Call->addArg(Op);
+ Call->addArg(ConstantInteger32::create(Ctx, IceType_i32, Size));
+ // play games to insert the call before the access instruction
+ InstList::iterator Next = Context.getNext();
+ Context.setInsertPoint(Context.getCur());
+ Context.insert(Call);
+ Context.setNext(Next);
+}
+
void ASanInstrumentation::instrumentStart(Cfg *Func) {
Constant *ShadowMemInit =
Ctx->getConstantExternSym(Ctx->getGlobalString("__asan_init"));
constexpr SizeT NumArgs = 0;
constexpr Variable *Void = nullptr;
constexpr bool NoTailCall = false;
-
auto *Call = InstCall::create(Func, NumArgs, Void, ShadowMemInit, NoTailCall);
Func->getEntryNode()->getInsts().push_front(Call);
}
« no previous file with comments | « src/IceASanInstrumentation.h ('k') | src/IceCompileServer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698