diff options
author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2012-11-29 13:43:05 +0000 |
---|---|---|
committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2012-11-29 13:43:05 +0000 |
commit | af4451b37e381c643144dc00614e63eef8db6082 (patch) | |
tree | 718015781b8fcbd578107217bb62bedaf33b3296 | |
parent | 2ea25f2f1cd29b617c768af504210127827fa2e3 (diff) | |
download | external_llvm-af4451b37e381c643144dc00614e63eef8db6082.zip external_llvm-af4451b37e381c643144dc00614e63eef8db6082.tar.gz external_llvm-af4451b37e381c643144dc00614e63eef8db6082.tar.bz2 |
[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
-rw-r--r-- | lib/Transforms/Instrumentation/MemorySanitizer.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/lib/Transforms/Instrumentation/MemorySanitizer.cpp index ed0f89b..8cc0084 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. |