[llvm-commits] [llvm] r168879 - /llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Thu Nov 29 05:43:05 PST 2012
Author: eugenis
Date: Thu Nov 29 07:43:05 2012
New Revision: 168879
URL: http://llvm.org/viewvc/llvm-project?rev=168879&view=rev
Log:
[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%.
Modified:
llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
Modified: llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp?rev=168879&r1=168878&r2=168879&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp Thu Nov 29 07:43:05 2012
@@ -503,15 +503,16 @@
/// 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.
More information about the llvm-commits
mailing list