From 16e8eda4b8b0825d38ba37d31c99edba0fb25482 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 6 Mar 2009 02:23:01 +0000 Subject: [PATCH] Fix ScheduleDAGRRList::CopyAndMoveSuccessors' handling of nodes with multiple chain operands. This can occur when the scheduler has added chain operands to a node that already has a chain operand, in order to handle physical register dependencies. This fixes an llvm-gcc bootstrap failure on x86-64 introduced in r66058. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66240 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../SelectionDAG/ScheduleDAGRRList.cpp | 14 ++++---- .../CodeGen/X86/2009-03-05-burr-list-crash.ll | 35 +++++++++++++++++++ 2 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 test/CodeGen/X86/2009-03-05-burr-list-crash.ll diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp index a89564ba515..e505b7bcaf9 100644 --- a/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp +++ b/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp @@ -410,7 +410,7 @@ SUnit *ScheduleDAGRRList::CopyAndMoveSuccessors(SUnit *SU) { NewSU->isCommutable = true; ComputeLatency(NewSU); - SDep ChainPred; + SmallVector ChainPreds; SmallVector ChainSuccs; SmallVector LoadPreds; SmallVector NodePreds; @@ -418,7 +418,7 @@ SUnit *ScheduleDAGRRList::CopyAndMoveSuccessors(SUnit *SU) { for (SUnit::pred_iterator I = SU->Preds.begin(), E = SU->Preds.end(); I != E; ++I) { if (I->isCtrl()) - ChainPred = *I; + ChainPreds.push_back(*I); else if (I->getSUnit()->getNode() && I->getSUnit()->getNode()->isOperandOf(LoadNode)) LoadPreds.push_back(*I); @@ -433,17 +433,17 @@ SUnit *ScheduleDAGRRList::CopyAndMoveSuccessors(SUnit *SU) { NodeSuccs.push_back(*I); } - if (ChainPred.getSUnit()) { - RemovePred(SU, ChainPred); + for (unsigned i = 0, e = ChainPreds.size(); i != e; ++i) { + const SDep &Pred = ChainPreds[i]; + RemovePred(SU, Pred); if (isNewLoad) - AddPred(LoadSU, ChainPred); + AddPred(LoadSU, Pred); } for (unsigned i = 0, e = LoadPreds.size(); i != e; ++i) { const SDep &Pred = LoadPreds[i]; RemovePred(SU, Pred); - if (isNewLoad) { + if (isNewLoad) AddPred(LoadSU, Pred); - } } for (unsigned i = 0, e = NodePreds.size(); i != e; ++i) { const SDep &Pred = NodePreds[i]; diff --git a/test/CodeGen/X86/2009-03-05-burr-list-crash.ll b/test/CodeGen/X86/2009-03-05-burr-list-crash.ll new file mode 100644 index 00000000000..ccedaae9322 --- /dev/null +++ b/test/CodeGen/X86/2009-03-05-burr-list-crash.ll @@ -0,0 +1,35 @@ +; RUN: llvm-as < %s | llc + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" +target triple = "x86_64-unknown-linux-gnu" +external global i32 ; :0 [#uses=1] + +declare i64 @strlen(i8* nocapture) nounwind readonly + +define fastcc i8* @1(i8*) nounwind { + br i1 false, label %3, label %2 + +;