[PATCH] Skip promotable allocas to improve performance at -O0

Dmitry Vyukov dvyukov at google.com
Tue Feb 24 06:05:23 PST 2015


On Tue, Feb 24, 2015 at 5:57 AM, Anna Zaks <zaks.anna at gmail.com> wrote:
> I've addressed the outstanding comments:
>
> - Refactored the code to reuse isInterestingAlloca() from within isInterestingMemoryAccess().
> - Addressed Kostya's latest comments about "if" re-structuring as well.
> - Kuba is helping out by modifying the compiler-rt tests so that they are not sensitive to optimization levels :)
>
> Kostya,
> As I've commented on the other thread, I don't think http://reviews.llvm.org/D7583 is currently doing the right thing (skipping "inbounds" geps). Though, I do believe we can achieve optimizations by building on top of this and excluding allocas that only have constant and provably in bounds accesses.

Thanks for the review of D7583, Anna!

I've changed the predicate to be:

// isInboundsAccess returns true if Addr is always inbounds with respect to its
// base object. For example, it is a field access or an array access with
// constant inbounds index.
bool AddressSanitizer::isInboundsAccess(ObjectSizeOffsetEvaluator
&ObjSizeEval, Value *Addr) {
  SizeOffsetEvalType SizeOffset = ObjSizeEval.compute(Addr);
  if (!ObjSizeEval.bothKnown(SizeOffset) ||
      !isa<ConstantInt>(SizeOffset.first) ||
      !isa<ConstantInt>(SizeOffset.second))
    return false;
  Type *OrigTy = cast<PointerType>(Addr->getType())->getElementType();
  uint32_t TypeSize = DL->getTypeStoreSizeInBits(OrigTy);
  int64_t Size = dyn_cast<ConstantInt>(SizeOffset.first)->getSExtValue();
  int64_t Offset = dyn_cast<ConstantInt>(SizeOffset.second)->getSExtValue();
  return Offset >= 0 && Offset + TypeSize / 8 <= Size;
}




More information about the llvm-commits mailing list