From af4451b37e381c643144dc00614e63eef8db6082 Mon Sep 17 00:00:00 2001 From: Evgeniy Stepanov Date: Thu, 29 Nov 2012 13:43:05 +0000 Subject: [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 --- lib/Transforms/Instrumentation/MemorySanitizer.cpp | 7 ++++--- 1 file 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 { /// 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. -- cgit v1.1