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

Unified Diff: src/IceASanInstrumentation.cpp

Issue 2183683003: Subzero: Removed unnecessary global access checks (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Small fixes Created 4 years, 5 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/instrumentload.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 b53de0d4063186e5e58d8e8f58269a200bf5027a..e3203b36225ed5b4fa6cdc7799f079dd9ee5c2b6 100644
--- a/src/IceASanInstrumentation.cpp
+++ b/src/IceASanInstrumentation.cpp
@@ -132,6 +132,8 @@ void ASanInstrumentation::instrumentGlobals(VariableDeclarationList &Globals) {
NewGlobals.push_back(Global);
NewGlobals.push_back(RzRight);
RzGlobalsNum += 2;
+
+ GlobalSizes.insert({Global->getName(), Global->getNumBytes()});
}
// Replace old list of globals, without messing up arena allocators
@@ -297,6 +299,8 @@ void ASanInstrumentation::instrumentAccess(LoweringContext &Context,
if (LocalSize != ICE_TLS_GET_FIELD(LocalVars)->end() &&
LocalSize->second >= Size)
return;
+ if (isOkGlobalAccess(Op, Size))
+ return;
constexpr SizeT NumArgs = 2;
constexpr Variable *Void = nullptr;
constexpr bool NoTailCall = false;
@@ -311,6 +315,16 @@ void ASanInstrumentation::instrumentAccess(LoweringContext &Context,
Context.setNext(Next);
}
+// TODO(tlively): Trace back load and store addresses to find their real offsets
+bool ASanInstrumentation::isOkGlobalAccess(Operand *Op, SizeT Size) {
+ auto *Reloc = llvm::dyn_cast<ConstantRelocatable>(Op);
+ if (Reloc == nullptr)
+ return false;
+ RelocOffsetT Offset = Reloc->getOffset();
+ GlobalSizeMap::iterator GlobalSize = GlobalSizes.find(Reloc->getName());
+ return GlobalSize != GlobalSizes.end() && GlobalSize->second - Offset >= Size;
+}
+
void ASanInstrumentation::instrumentRet(LoweringContext &Context, InstRet *) {
Cfg *Func = Context.getNode()->getCfg();
InstList::iterator Next = Context.getNext();
« no previous file with comments | « src/IceASanInstrumentation.h ('k') | tests_lit/asan_tests/instrumentload.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698