mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-30 19:35:54 +00:00
Make array bound checks optional and disabled by default.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1725 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0cac4b8f3f
commit
c0fbd57c97
@ -26,7 +26,7 @@ using std::cerr;
|
|||||||
|
|
||||||
cl::Flag QuietMode ("quiet" , "Do not emit any non-program output");
|
cl::Flag QuietMode ("quiet" , "Do not emit any non-program output");
|
||||||
cl::Alias QuietModeA("q" , "Alias for -quiet", cl::NoFlags, QuietMode);
|
cl::Alias QuietModeA("q" , "Alias for -quiet", cl::NoFlags, QuietMode);
|
||||||
|
cl::Flag ArrayChecksEnabled("array-checks", "Enable array bound checks");
|
||||||
|
|
||||||
// Create a TargetData structure to handle memory addressing and size/alignment
|
// Create a TargetData structure to handle memory addressing and size/alignment
|
||||||
// computations
|
// computations
|
||||||
@ -797,7 +797,7 @@ static PointerTy getElementOffset(MemAccessInst *I, ExecutionContext &SF) {
|
|||||||
assert(I->getOperand(ArgOff)->getType() == Type::UIntTy);
|
assert(I->getOperand(ArgOff)->getType() == Type::UIntTy);
|
||||||
unsigned Idx = getOperandValue(I->getOperand(ArgOff++), SF).UIntVal;
|
unsigned Idx = getOperandValue(I->getOperand(ArgOff++), SF).UIntVal;
|
||||||
if (const ArrayType *AT = dyn_cast<ArrayType>(ST))
|
if (const ArrayType *AT = dyn_cast<ArrayType>(ST))
|
||||||
if (Idx >= AT->getNumElements()) {
|
if (Idx >= AT->getNumElements() && ArrayChecksEnabled) {
|
||||||
cerr << "Out of range memory access to element #" << Idx
|
cerr << "Out of range memory access to element #" << Idx
|
||||||
<< " of a " << AT->getNumElements() << " element array."
|
<< " of a " << AT->getNumElements() << " element array."
|
||||||
<< " Subscript #" << (ArgOff-I->getFirstIndexOperandNumber())
|
<< " Subscript #" << (ArgOff-I->getFirstIndexOperandNumber())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user