From 963b70bbf8af4deec80aab4dfb0480fffc9f2845 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 21 May 2002 18:05:19 +0000 Subject: [PATCH] Fix bug: test/Regression/CBackend/2002-05-21-MissingReturn.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2690 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/CBackend/CBackend.cpp | 4 +++- lib/Target/CBackend/Writer.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index dd5f0b1eb52..3003a02064b 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -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()) { diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index dd5f0b1eb52..3003a02064b 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -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()) {