summaryrefslogtreecommitdiff
path: root/lib
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
commitaf4451b37e381c643144dc00614e63eef8db6082 (patch)
tree718015781b8fcbd578107217bb62bedaf33b3296 /lib
parent2ea25f2f1cd29b617c768af504210127827fa2e3 (diff)
downloadllvm-af4451b37e381c643144dc00614e63eef8db6082.tar.gz
llvm-af4451b37e381c643144dc00614e63eef8db6082.tar.bz2
llvm-af4451b37e381c643144dc00614e63eef8db6082.tar.xz
[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%. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168879 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Instrumentation/MemorySanitizer.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/lib/Transforms/Instrumentation/MemorySanitizer.cpp
index ed0f89bfb5..8cc0084db5 100644
--- a/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ b/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.