aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-04-23 19:15:13 +0000
committerChris Lattner <sabre@nondot.org>2003-04-23 19:15:13 +0000
commitf1acd9623c642e2ad16c74a803d5c10934cb8402 (patch)
tree7fe72b0cecb074d26f6f66190457a25aec1a9117
parentf5612b76bcbc8290b44f0e3deb677ee6ff0a95b8 (diff)
Fix problem where labels were being incorrectly elided, and fix problem
where PHI copies where not emitted for the default label of switch insts git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5882 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/CBackend/CBackend.cpp7
-rw-r--r--lib/Target/CBackend/Writer.cpp7
2 files changed, 8 insertions, 6 deletions
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp
index f9ddc7d8c4..b9e27acf57 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/lib/Target/CBackend/CBackend.cpp
@@ -817,7 +817,8 @@ void CWriter::printFunction(Function *F) {
for (Value::use_iterator UI = BB->use_begin(), UE = BB->use_end();
UI != UE; ++UI)
if (TerminatorInst *TI = dyn_cast<TerminatorInst>(*UI))
- if (TI != Prev->getTerminator()) {
+ if (TI != Prev->getTerminator() ||
+ isa<SwitchInst>(Prev->getTerminator())) {
NeedsLabel = true;
break;
}
@@ -867,8 +868,8 @@ void CWriter::visitReturnInst(ReturnInst &I) {
void CWriter::visitSwitchInst(SwitchInst &SI) {
Out << " switch (";
writeOperand(SI.getOperand(0));
- Out << ") {\n default: goto ";
- writeOperand(SI.getDefaultDest());
+ Out << ") {\n default:\n";
+ printBranchToBlock(SI.getParent(), SI.getDefaultDest(), 2);
Out << ";\n";
for (unsigned i = 2, e = SI.getNumOperands(); i != e; i += 2) {
Out << " case ";
diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp
index f9ddc7d8c4..b9e27acf57 100644
--- a/lib/Target/CBackend/Writer.cpp
+++ b/lib/Target/CBackend/Writer.cpp
@@ -817,7 +817,8 @@ void CWriter::printFunction(Function *F) {
for (Value::use_iterator UI = BB->use_begin(), UE = BB->use_end();
UI != UE; ++UI)
if (TerminatorInst *TI = dyn_cast<TerminatorInst>(*UI))
- if (TI != Prev->getTerminator()) {
+ if (TI != Prev->getTerminator() ||
+ isa<SwitchInst>(Prev->getTerminator())) {
NeedsLabel = true;
break;
}
@@ -867,8 +868,8 @@ void CWriter::visitReturnInst(ReturnInst &I) {
void CWriter::visitSwitchInst(SwitchInst &SI) {
Out << " switch (";
writeOperand(SI.getOperand(0));
- Out << ") {\n default: goto ";
- writeOperand(SI.getDefaultDest());
+ Out << ") {\n default:\n";
+ printBranchToBlock(SI.getParent(), SI.getDefaultDest(), 2);
Out << ";\n";
for (unsigned i = 2, e = SI.getNumOperands(); i != e; i += 2) {
Out << " case ";