[llvm-commits] CVS: llvm/lib/Transforms/Utils/InlineFunction.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Oct 17 16:21:18 PDT 2004



Changes in directory llvm/lib/Transforms/Utils:

InlineFunction.cpp updated: 1.27 -> 1.28
---
Log message:

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.


---
Diffs of the changes:  (+8 -4)

Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
diff -u llvm/lib/Transforms/Utils/InlineFunction.cpp:1.27 llvm/lib/Transforms/Utils/InlineFunction.cpp:1.28
--- llvm/lib/Transforms/Utils/InlineFunction.cpp:1.27	Wed Sep 15 12:06:42 2004
+++ llvm/lib/Transforms/Utils/InlineFunction.cpp	Sun Oct 17 18:21:07 2004
@@ -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 @@
     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...






More information about the llvm-commits mailing list