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/IceASanInstrumentation.cpp

Issue 2235023002: Subzero: Elide redundant access checks within basic blocks (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 4 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/IceASanInstrumentation.h ('k') | tests_lit/asan_tests/elidelocalchecks.ll » ('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 62862990b7c67cdbdc36799b61b3290efb4cf2d0..9333d16d310a21a761e6863045bcba049c97f15a 100644
--- a/src/IceASanInstrumentation.cpp
+++ b/src/IceASanInstrumentation.cpp
@@ -70,6 +70,8 @@ llvm::NaClBitcodeRecord::RecordVector sizeToByteVec(SizeT Size) {
ICE_TLS_DEFINE_FIELD(VarSizeMap *, ASanInstrumentation, LocalVars);
ICE_TLS_DEFINE_FIELD(std::vector<InstStore *> *, ASanInstrumentation,
LocalDtors);
+ICE_TLS_DEFINE_FIELD(CfgNode *, ASanInstrumentation, CurNode);
+ICE_TLS_DEFINE_FIELD(VarSizeMap *, ASanInstrumentation, CheckedVars);
bool ASanInstrumentation::isInstrumentable(Cfg *Func) {
std::string FuncName = Func->getFunctionName().toStringOrEmpty();
@@ -329,6 +331,23 @@ void ASanInstrumentation::instrumentStore(LoweringContext &Context,
void ASanInstrumentation::instrumentAccess(LoweringContext &Context,
Operand *Op, SizeT Size,
Constant *CheckFunc) {
+ // Skip redundant checks within basic blocks
+ VarSizeMap *Checked = ICE_TLS_GET_FIELD(CheckedVars);
+ if (ICE_TLS_GET_FIELD(CurNode) != Context.getNode()) {
+ ICE_TLS_SET_FIELD(CurNode, Context.getNode());
+ if (Checked == NULL) {
+ Checked = new VarSizeMap();
+ ICE_TLS_SET_FIELD(CheckedVars, Checked);
+ }
+ Checked->clear();
+ }
+ VarSizeMap::iterator PrevCheck = Checked->find(Op);
+ if (PrevCheck != Checked->end() && PrevCheck->second >= Size)
+ return;
+ else
Karl 2016/08/11 14:51:17 Nit: The typical style is to drop the else keywor
+ Checked->insert({Op, Size});
+
+ // check for known good local access
VarSizeMap::iterator LocalSize = ICE_TLS_GET_FIELD(LocalVars)->find(Op);
if (LocalSize != ICE_TLS_GET_FIELD(LocalVars)->end() &&
LocalSize->second >= Size)
« no previous file with comments | « src/IceASanInstrumentation.h ('k') | tests_lit/asan_tests/elidelocalchecks.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698