summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/InlineFunction.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-10-17 23:21:07 +0000
committerChris Lattner <sabre@nondot.org>2004-10-17 23:21:07 +0000
commit6e79e55aeab580fcf3816ba13669a3b3d7d1662f (patch)
treede24497c7d16c3b6677e00b787861229e494c3e2 /llvm/lib/Transforms/Utils/InlineFunction.cpp
parent5f8becb224f715d8bfed46e7079571574895af24 (diff)
downloadbcm5719-llvm-6e79e55aeab580fcf3816ba13669a3b3d7d1662f.tar.gz
bcm5719-llvm-6e79e55aeab580fcf3816ba13669a3b3d7d1662f.zip
Fix Regression/Transforms/Inline/2004-10-17-InlineFunctionWithoutReturn.ll
If a function had no return instruction in it, and the result of the inlined call instruction was used, we would crash. llvm-svn: 17104
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/InlineFunction.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index 9f47825454a..77cf111b075 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -16,7 +16,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Transforms/Utils/Cloning.h"
-#include "llvm/Constant.h"
+#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
#include "llvm/Instructions.h"
@@ -316,12 +316,16 @@ bool llvm::InlineFunction(CallSite CS) {
ReturnBB->replaceAllUsesWith(AfterCallBB);
// Delete the return instruction now and empty ReturnBB now.
- Returns[0]->getParent()->getInstList().erase(Returns[0]);
- Caller->getBasicBlockList().erase(ReturnBB);
+ Returns[0]->eraseFromParent();
+ ReturnBB->eraseFromParent();
+ } else if (!TheCall->use_empty()) {
+ // No returns, but something is using the return value of the call. Just
+ // nuke the result.
+ TheCall->replaceAllUsesWith(UndefValue::get(TheCall->getType()));
}
// Since we are now done with the Call/Invoke, we can delete it.
- TheCall->getParent()->getInstList().erase(TheCall);
+ TheCall->eraseFromParent();
// We should always be able to fold the entry block of the function into the
// single predecessor of the block...
OpenPOWER on IntegriCloud