mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 00:32:55 +00:00
Selecting the address from a very long chain of GEPs can blow the stack.
The recursive nature of the address selection code can cause the stack to explode if there is a long chain of GEPs. Convert the recursive bit into a iterative method to avoid this. <rdar://problem/12445434> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191252 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7533165612
commit
cb3023ae51
@ -347,6 +347,7 @@ bool X86FastISel::X86FastEmitExtend(ISD::NodeType Opc, EVT DstVT,
|
||||
/// X86SelectAddress - Attempt to fill in an address from the given value.
|
||||
///
|
||||
bool X86FastISel::X86SelectAddress(const Value *V, X86AddressMode &AM) {
|
||||
redo_gep:
|
||||
const User *U = NULL;
|
||||
unsigned Opcode = Instruction::UserOp1;
|
||||
if (const Instruction *I = dyn_cast<Instruction>(V)) {
|
||||
@ -469,16 +470,24 @@ bool X86FastISel::X86SelectAddress(const Value *V, X86AddressMode &AM) {
|
||||
goto unsupported_gep;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for displacement overflow.
|
||||
if (!isInt<32>(Disp))
|
||||
break;
|
||||
// Ok, the GEP indices were covered by constant-offset and scaled-index
|
||||
// addressing. Update the address state and move on to examining the base.
|
||||
|
||||
AM.IndexReg = IndexReg;
|
||||
AM.Scale = Scale;
|
||||
AM.Disp = (uint32_t)Disp;
|
||||
if (X86SelectAddress(U->getOperand(0), AM))
|
||||
|
||||
if (const GetElementPtrInst *GEP =
|
||||
dyn_cast<GetElementPtrInst>(U->getOperand(0))) {
|
||||
// Ok, the GEP indices were covered by constant-offset and scaled-index
|
||||
// addressing. Update the address state and move on to examining the base.
|
||||
V = GEP;
|
||||
goto redo_gep;
|
||||
} else if (X86SelectAddress(U->getOperand(0), AM)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If we couldn't merge the gep value into this addr mode, revert back to
|
||||
// our address and just match the value instead of completely failing.
|
||||
|
25607
test/CodeGen/X86/large-gep-chain.ll
Normal file
25607
test/CodeGen/X86/large-gep-chain.ll
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user