[PATCH] D23354: [compiler-rt] Suport dynamic shadow address instrumentation
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 10 09:53:46 PDT 2016
rnk added inline comments.
================
Comment at: lib/Transforms/Instrumentation/AddressSanitizer.cpp:445
@@ -437,1 +444,3 @@
+ && !(Mapping.Offset & (Mapping.Offset - 1))
+ && Mapping.Offset != ~(uint64_t)0;
----------------
Can we make a kDynamicShadowSentinel for this?
================
Comment at: lib/Transforms/Instrumentation/AddressSanitizer.cpp:906
@@ -893,1 +905,3 @@
// (Shadow >> scale) | offset
+ Value* ShadowBase;
+ if (LocalDynamicShadow)
----------------
LLVM typically uses right leaning pointers and references.
================
Comment at: lib/Transforms/Instrumentation/AddressSanitizer.cpp:1770
@@ +1769,3 @@
+ IRBuilder<> IRB(&F.front().front());
+ LocalDynamicShadow = IRB.CreateAlloca(IntptrTy);
+ assert(LocalDynamicShadow->isStaticAlloca());
----------------
Why create a local alloca and then load from it? This might end up being really slow in -O0 if we reload the shadow base from the stack before every user memory access. If we know we're in the entry block, we should be able to skip the alloca and change this to:
Value *GlobalDynamicAddress = F.getParent()->getOrInsertGlobal(
kAsanShadowMemoryDynamicAddress, IntptrTy);
LocalDynamicShadow = IRB.CreateLoad(GlobalDynamicAddress);
We can then skip the extra load in memToShadow and use LocalDynamicShadow directly.
https://reviews.llvm.org/D23354
More information about the llvm-commits
mailing list