summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/BoundsChecking.cpp
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2012-05-25 21:15:17 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2012-05-25 21:15:17 +0000
commite9b0bdf80467029e99e94065463020df1f037202 (patch)
tree53e7a236c90240e75a329c09c183c35e77054b5a /llvm/lib/Transforms/Scalar/BoundsChecking.cpp
parent7d49c9c8610f1d8756292efa875717470db1d067 (diff)
downloadbcm5719-llvm-e9b0bdf80467029e99e94065463020df1f037202.tar.gz
bcm5719-llvm-e9b0bdf80467029e99e94065463020df1f037202.zip
bounds checking: add support for byval arguments
llvm-svn: 157498
Diffstat (limited to 'llvm/lib/Transforms/Scalar/BoundsChecking.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/BoundsChecking.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/BoundsChecking.cpp b/llvm/lib/Transforms/Scalar/BoundsChecking.cpp
index 4c3dea2317a..7b1a4170408 100644
--- a/llvm/lib/Transforms/Scalar/BoundsChecking.cpp
+++ b/llvm/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;
OpenPOWER on IntegriCloud