Fix bug: test/Regression/CBackend/2002-05-21-MissingReturn.ll
authorChris Lattner <sabre@nondot.org>
Tue, 21 May 2002 18:05:19 +0000 (18:05 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 21 May 2002 18:05:19 +0000 (18:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2690 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/CBackend/CBackend.cpp
lib/Target/CBackend/Writer.cpp

index dd5f0b1eb52e706b0bbbcaefe96ee71533366c97..3003a02064bcf94e11d626df2283c23055b4d6ee 100644 (file)
@@ -567,8 +567,10 @@ void CWriter::printFunction(Function *F) {
 void CWriter::visitReturnInst(ReturnInst *I) {
   // Don't output a void return if this is the last basic block in the function
   if (I->getNumOperands() == 0 && 
-      *(I->getParent()->getParent()->end()-1) == I->getParent())
+      *(I->getParent()->getParent()->end()-1) == I->getParent() &&
+      !I->getParent()->size() == 1) {
     return;
+  }
 
   Out << "  return";
   if (I->getNumOperands()) {
index dd5f0b1eb52e706b0bbbcaefe96ee71533366c97..3003a02064bcf94e11d626df2283c23055b4d6ee 100644 (file)
@@ -567,8 +567,10 @@ void CWriter::printFunction(Function *F) {
 void CWriter::visitReturnInst(ReturnInst *I) {
   // Don't output a void return if this is the last basic block in the function
   if (I->getNumOperands() == 0 && 
-      *(I->getParent()->getParent()->end()-1) == I->getParent())
+      *(I->getParent()->getParent()->end()-1) == I->getParent() &&
+      !I->getParent()->size() == 1) {
     return;
+  }
 
   Out << "  return";
   if (I->getNumOperands()) {