diff options
Diffstat (limited to 'lib/Transforms/Scalar/BoundsChecking.cpp')
-rw-r--r-- | lib/Transforms/Scalar/BoundsChecking.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/BoundsChecking.cpp b/lib/Transforms/Scalar/BoundsChecking.cpp index 4c3dea2317..7b1a417040 100644 --- a/lib/Transforms/Scalar/BoundsChecking.cpp +++ b/lib/Transforms/Scalar/BoundsChecking.cpp @@ -104,7 +104,6 @@ void BoundsChecking::emitBranchToTrap(Value *Cmp) { BasicBlock *Cont = OldBB->splitBasicBlock(Inst); OldBB->getTerminator()->eraseFromParent(); - // FIXME: add unlikely branch taken metadata? if (Cmp) BranchInst::Create(getTrapBB(), Cont, Cmp, OldBB); else @@ -152,6 +151,15 @@ ConstTriState BoundsChecking::computeAllocSize(Value *Alloc, uint64_t &Size, SizeValue = Builder->CreateMul(SizeValue, ArraySize); return NotConst; + // function arguments + } else if (Argument *A = dyn_cast<Argument>(Alloc)) { + if (!A->hasByValAttr()) + return Dunno; + + PointerType *PT = cast<PointerType>(A->getType()); + Size = TD->getTypeAllocSize(PT->getElementType()); + return Const; + // ptr = select(ptr1, ptr2) } else if (SelectInst *SI = dyn_cast<SelectInst>(Alloc)) { uint64_t SizeFalse; |