mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-14 15:28:20 +00:00
Avoid adding PHI arguments for a predecessor that has gone away when a BRCOND was constant folded.
This fixes PR5980. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93184 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1017,8 +1017,7 @@ SelectionDAGISel::FinishBasicBlock() {
|
|||||||
for (unsigned j = 0, ej = SDB->BitTestCases[i].Cases.size();
|
for (unsigned j = 0, ej = SDB->BitTestCases[i].Cases.size();
|
||||||
j != ej; ++j) {
|
j != ej; ++j) {
|
||||||
MachineBasicBlock* cBB = SDB->BitTestCases[i].Cases[j].ThisBB;
|
MachineBasicBlock* cBB = SDB->BitTestCases[i].Cases[j].ThisBB;
|
||||||
if (cBB->succ_end() !=
|
if (cBB->isSuccessor(PHIBB)) {
|
||||||
std::find(cBB->succ_begin(),cBB->succ_end(), PHIBB)) {
|
|
||||||
PHI->addOperand(MachineOperand::CreateReg(SDB->PHINodesToUpdate[pi].second,
|
PHI->addOperand(MachineOperand::CreateReg(SDB->PHINodesToUpdate[pi].second,
|
||||||
false));
|
false));
|
||||||
PHI->addOperand(MachineOperand::CreateMBB(cBB));
|
PHI->addOperand(MachineOperand::CreateMBB(cBB));
|
||||||
@@ -1067,7 +1066,7 @@ SelectionDAGISel::FinishBasicBlock() {
|
|||||||
(MachineOperand::CreateMBB(SDB->JTCases[i].first.HeaderBB));
|
(MachineOperand::CreateMBB(SDB->JTCases[i].first.HeaderBB));
|
||||||
}
|
}
|
||||||
// JT BB. Just iterate over successors here
|
// JT BB. Just iterate over successors here
|
||||||
if (BB->succ_end() != std::find(BB->succ_begin(),BB->succ_end(), PHIBB)) {
|
if (BB->isSuccessor(PHIBB)) {
|
||||||
PHI->addOperand
|
PHI->addOperand
|
||||||
(MachineOperand::CreateReg(SDB->PHINodesToUpdate[pi].second, false));
|
(MachineOperand::CreateReg(SDB->PHINodesToUpdate[pi].second, false));
|
||||||
PHI->addOperand(MachineOperand::CreateMBB(BB));
|
PHI->addOperand(MachineOperand::CreateMBB(BB));
|
||||||
@@ -1113,20 +1112,26 @@ SelectionDAGISel::FinishBasicBlock() {
|
|||||||
SDB->EdgeMapping.find(BB);
|
SDB->EdgeMapping.find(BB);
|
||||||
if (EI != SDB->EdgeMapping.end())
|
if (EI != SDB->EdgeMapping.end())
|
||||||
ThisBB = EI->second;
|
ThisBB = EI->second;
|
||||||
|
|
||||||
|
// BB may have been removed from the CFG if a branch was constant folded.
|
||||||
|
if (ThisBB->isSuccessor(BB)) {
|
||||||
for (MachineBasicBlock::iterator Phi = BB->begin();
|
for (MachineBasicBlock::iterator Phi = BB->begin();
|
||||||
Phi != BB->end() && Phi->getOpcode() == TargetInstrInfo::PHI; ++Phi){
|
Phi != BB->end() && Phi->getOpcode() == TargetInstrInfo::PHI;
|
||||||
// This value for this PHI node is recorded in PHINodesToUpdate, get it.
|
++Phi) {
|
||||||
|
// This value for this PHI node is recorded in PHINodesToUpdate.
|
||||||
for (unsigned pn = 0; ; ++pn) {
|
for (unsigned pn = 0; ; ++pn) {
|
||||||
assert(pn != SDB->PHINodesToUpdate.size() &&
|
assert(pn != SDB->PHINodesToUpdate.size() &&
|
||||||
"Didn't find PHI entry!");
|
"Didn't find PHI entry!");
|
||||||
if (SDB->PHINodesToUpdate[pn].first == Phi) {
|
if (SDB->PHINodesToUpdate[pn].first == Phi) {
|
||||||
Phi->addOperand(MachineOperand::CreateReg(SDB->PHINodesToUpdate[pn].
|
Phi->addOperand(MachineOperand::
|
||||||
second, false));
|
CreateReg(SDB->PHINodesToUpdate[pn].second,
|
||||||
|
false));
|
||||||
Phi->addOperand(MachineOperand::CreateMBB(ThisBB));
|
Phi->addOperand(MachineOperand::CreateMBB(ThisBB));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Don't process RHS if same block as LHS.
|
// Don't process RHS if same block as LHS.
|
||||||
if (BB == SDB->SwitchCases[i].FalseBB)
|
if (BB == SDB->SwitchCases[i].FalseBB)
|
||||||
|
97
test/CodeGen/X86/2010-01-11-ExtraPHIArg.ll
Normal file
97
test/CodeGen/X86/2010-01-11-ExtraPHIArg.ll
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
; RUN: llc -verify-machineinstrs < %s
|
||||||
|
;
|
||||||
|
; The lowering of a switch combined with constand folding would leave spurious extra arguments on a PHI instruction.
|
||||||
|
;
|
||||||
|
target triple = "x86_64-apple-darwin10"
|
||||||
|
|
||||||
|
define void @foo() {
|
||||||
|
br label %cond_true813.i
|
||||||
|
|
||||||
|
cond_true813.i: ; preds = %0
|
||||||
|
br i1 false, label %cond_true818.i, label %cond_next1146.i
|
||||||
|
|
||||||
|
cond_true818.i: ; preds = %cond_true813.i
|
||||||
|
br i1 false, label %recog_memoized.exit52, label %cond_next1146.i
|
||||||
|
|
||||||
|
recog_memoized.exit52: ; preds = %cond_true818.i
|
||||||
|
switch i32 0, label %bb886.i.preheader [
|
||||||
|
i32 0, label %bb907.i
|
||||||
|
i32 44, label %bb866.i
|
||||||
|
i32 103, label %bb874.i
|
||||||
|
i32 114, label %bb874.i
|
||||||
|
]
|
||||||
|
|
||||||
|
bb857.i: ; preds = %bb886.i, %bb866.i
|
||||||
|
%tmp862.i494.24 = phi i8* [ null, %bb866.i ], [ %tmp862.i494.26, %bb886.i ] ; <i8*> [#uses=1]
|
||||||
|
switch i32 0, label %bb886.i.preheader [
|
||||||
|
i32 0, label %bb907.i
|
||||||
|
i32 44, label %bb866.i
|
||||||
|
i32 103, label %bb874.i
|
||||||
|
i32 114, label %bb874.i
|
||||||
|
]
|
||||||
|
|
||||||
|
bb866.i.loopexit: ; preds = %bb874.i
|
||||||
|
br label %bb866.i
|
||||||
|
|
||||||
|
bb866.i.loopexit31: ; preds = %cond_true903.i
|
||||||
|
br label %bb866.i
|
||||||
|
|
||||||
|
bb866.i: ; preds = %bb866.i.loopexit31, %bb866.i.loopexit, %bb857.i, %recog_memoized.exit52
|
||||||
|
br i1 false, label %bb907.i, label %bb857.i
|
||||||
|
|
||||||
|
bb874.i.preheader.loopexit: ; preds = %cond_true903.i, %cond_true903.i
|
||||||
|
ret void
|
||||||
|
|
||||||
|
bb874.i: ; preds = %bb857.i, %bb857.i, %recog_memoized.exit52, %recog_memoized.exit52
|
||||||
|
switch i32 0, label %bb886.i.preheader.loopexit [
|
||||||
|
i32 0, label %bb907.i
|
||||||
|
i32 44, label %bb866.i.loopexit
|
||||||
|
i32 103, label %bb874.i.backedge
|
||||||
|
i32 114, label %bb874.i.backedge
|
||||||
|
]
|
||||||
|
|
||||||
|
bb874.i.backedge: ; preds = %bb874.i, %bb874.i
|
||||||
|
ret void
|
||||||
|
|
||||||
|
bb886.i.preheader.loopexit: ; preds = %bb874.i
|
||||||
|
ret void
|
||||||
|
|
||||||
|
bb886.i.preheader: ; preds = %bb857.i, %recog_memoized.exit52
|
||||||
|
%tmp862.i494.26 = phi i8* [ undef, %recog_memoized.exit52 ], [ %tmp862.i494.24, %bb857.i ] ; <i8*> [#uses=1]
|
||||||
|
br label %bb886.i
|
||||||
|
|
||||||
|
bb886.i: ; preds = %cond_true903.i, %bb886.i.preheader
|
||||||
|
br i1 false, label %bb857.i, label %cond_true903.i
|
||||||
|
|
||||||
|
cond_true903.i: ; preds = %bb886.i
|
||||||
|
switch i32 0, label %bb886.i [
|
||||||
|
i32 0, label %bb907.i
|
||||||
|
i32 44, label %bb866.i.loopexit31
|
||||||
|
i32 103, label %bb874.i.preheader.loopexit
|
||||||
|
i32 114, label %bb874.i.preheader.loopexit
|
||||||
|
]
|
||||||
|
|
||||||
|
bb907.i: ; preds = %cond_true903.i, %bb874.i, %bb866.i, %bb857.i, %recog_memoized.exit52
|
||||||
|
br i1 false, label %cond_next1146.i, label %cond_true910.i
|
||||||
|
|
||||||
|
cond_true910.i: ; preds = %bb907.i
|
||||||
|
ret void
|
||||||
|
|
||||||
|
cond_next1146.i: ; preds = %bb907.i, %cond_true818.i, %cond_true813.i
|
||||||
|
ret void
|
||||||
|
|
||||||
|
bb2060.i: ; No predecessors!
|
||||||
|
br i1 false, label %cond_true2064.i, label %bb2067.i
|
||||||
|
|
||||||
|
cond_true2064.i: ; preds = %bb2060.i
|
||||||
|
unreachable
|
||||||
|
|
||||||
|
bb2067.i: ; preds = %bb2060.i
|
||||||
|
ret void
|
||||||
|
|
||||||
|
cond_next3473: ; No predecessors!
|
||||||
|
ret void
|
||||||
|
|
||||||
|
cond_next3521: ; No predecessors!
|
||||||
|
ret void
|
||||||
|
}
|
Reference in New Issue
Block a user