From: John Criswell Date: Mon, 25 Oct 2004 18:30:09 +0000 (+0000) Subject: Modified switch generation so that only the phi values associated with the X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=30cc227fa79c253332ea805a3a78ddca72aea428;p=oota-llvm.git Modified switch generation so that only the phi values associated with the destination basic block are copied. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17212 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 7af9bfe4fa6..16d83c37717 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -1194,11 +1194,11 @@ void CWriter::visitReturnInst(ReturnInst &I) { } void CWriter::visitSwitchInst(SwitchInst &SI) { - printPHICopiesForSuccessors(SI.getParent(), 0); Out << " switch ("; writeOperand(SI.getOperand(0)); Out << ") {\n default:\n"; + printPHICopiesForSuccessor (SI.getParent(), SI.getDefaultDest(), 2); printBranchToBlock(SI.getParent(), SI.getDefaultDest(), 2); Out << ";\n"; for (unsigned i = 2, e = SI.getNumOperands(); i != e; i += 2) { @@ -1206,6 +1206,7 @@ void CWriter::visitSwitchInst(SwitchInst &SI) { writeOperand(SI.getOperand(i)); Out << ":\n"; BasicBlock *Succ = cast(SI.getOperand(i+1)); + printPHICopiesForSuccessor (SI.getParent(), Succ, 2); printBranchToBlock(SI.getParent(), Succ, 2); if (Succ == SI.getParent()->getNext()) Out << " break;\n"; diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index 7af9bfe4fa6..16d83c37717 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -1194,11 +1194,11 @@ void CWriter::visitReturnInst(ReturnInst &I) { } void CWriter::visitSwitchInst(SwitchInst &SI) { - printPHICopiesForSuccessors(SI.getParent(), 0); Out << " switch ("; writeOperand(SI.getOperand(0)); Out << ") {\n default:\n"; + printPHICopiesForSuccessor (SI.getParent(), SI.getDefaultDest(), 2); printBranchToBlock(SI.getParent(), SI.getDefaultDest(), 2); Out << ";\n"; for (unsigned i = 2, e = SI.getNumOperands(); i != e; i += 2) { @@ -1206,6 +1206,7 @@ void CWriter::visitSwitchInst(SwitchInst &SI) { writeOperand(SI.getOperand(i)); Out << ":\n"; BasicBlock *Succ = cast(SI.getOperand(i+1)); + printPHICopiesForSuccessor (SI.getParent(), Succ, 2); printBranchToBlock(SI.getParent(), Succ, 2); if (Succ == SI.getParent()->getNext()) Out << " break;\n";