summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2012-11-29 13:43:05 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2012-11-29 13:43:05 +0000
commit62ba6118281cf09a9ac6cd9f1428eaf99b81ae30 (patch)
treefcec8790541a177ccc50fbd81149e64e2c7c26b5 /llvm/lib/Transforms
parentda0072b676a62f9df1e3eb0444690607097ca698 (diff)
downloadbcm5719-llvm-62ba6118281cf09a9ac6cd9f1428eaf99b81ae30.tar.gz
bcm5719-llvm-62ba6118281cf09a9ac6cd9f1428eaf99b81ae30.zip
[msan] Optimize getOriginPtr.
Rewrite getOriginPtr in a way that lets subsequent optimizations factor out the common part of Shadow and Origin address calculation. Improves perf by up to 5%. llvm-svn: 168879
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index ed0f89bfb59..8cc0084db59 100644
--- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -503,15 +503,16 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
/// address.
///
/// OriginAddr = (ShadowAddr + OriginOffset) & ~3ULL
- /// = Addr & (~ShadowMask & ~3ULL) + OriginOffset
Value *getOriginPtr(Value *Addr, IRBuilder<> &IRB) {
Value *ShadowLong =
IRB.CreateAnd(IRB.CreatePointerCast(Addr, MS.IntptrTy),
- ConstantInt::get(MS.IntptrTy, ~MS.ShadowMask & ~3ULL));
+ ConstantInt::get(MS.IntptrTy, ~MS.ShadowMask));
Value *Add =
IRB.CreateAdd(ShadowLong,
ConstantInt::get(MS.IntptrTy, MS.OriginOffset));
- return IRB.CreateIntToPtr(Add, PointerType::get(IRB.getInt32Ty(), 0));
+ Value *SecondAnd =
+ IRB.CreateAnd(Add, ConstantInt::get(MS.IntptrTy, ~3ULL));
+ return IRB.CreateIntToPtr(SecondAnd, PointerType::get(IRB.getInt32Ty(), 0));
}
/// \brief Compute the shadow address for a given function argument.
OpenPOWER on IntegriCloud