mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-17 21:35:07 +00:00
bounds checking: add support for byval arguments
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157498 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
06a2f42d11
commit
d72d67da07
@ -104,7 +104,6 @@ void BoundsChecking::emitBranchToTrap(Value *Cmp) {
|
|||||||
BasicBlock *Cont = OldBB->splitBasicBlock(Inst);
|
BasicBlock *Cont = OldBB->splitBasicBlock(Inst);
|
||||||
OldBB->getTerminator()->eraseFromParent();
|
OldBB->getTerminator()->eraseFromParent();
|
||||||
|
|
||||||
// FIXME: add unlikely branch taken metadata?
|
|
||||||
if (Cmp)
|
if (Cmp)
|
||||||
BranchInst::Create(getTrapBB(), Cont, Cmp, OldBB);
|
BranchInst::Create(getTrapBB(), Cont, Cmp, OldBB);
|
||||||
else
|
else
|
||||||
@ -152,6 +151,15 @@ ConstTriState BoundsChecking::computeAllocSize(Value *Alloc, uint64_t &Size,
|
|||||||
SizeValue = Builder->CreateMul(SizeValue, ArraySize);
|
SizeValue = Builder->CreateMul(SizeValue, ArraySize);
|
||||||
return NotConst;
|
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)
|
// ptr = select(ptr1, ptr2)
|
||||||
} else if (SelectInst *SI = dyn_cast<SelectInst>(Alloc)) {
|
} else if (SelectInst *SI = dyn_cast<SelectInst>(Alloc)) {
|
||||||
uint64_t SizeFalse;
|
uint64_t SizeFalse;
|
||||||
|
@ -107,3 +107,12 @@ define void @f10(i64 %x, i64 %y) nounwind {
|
|||||||
%4 = load i128* %3, align 4
|
%4 = load i128* %3, align 4
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; CHECK: @f11
|
||||||
|
define void @f11(i128* byval %x) nounwind {
|
||||||
|
%1 = bitcast i128* %x to i8*
|
||||||
|
%2 = getelementptr inbounds i8* %1, i64 16
|
||||||
|
; CHECK: br label
|
||||||
|
%3 = load i8* %2, align 4
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user