mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-21 00:32:23 +00:00
[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
This commit is contained in:
parent
2ea25f2f1c
commit
af4451b37e
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user