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

Chris Lattner lattner at cs.uiuc.edu
Mon Jul 19 22:45:34 PDT 2004



Changes in directory llvm/lib/Transforms/Utils:

InlineFunction.cpp updated: 1.25 -> 1.26

---
Log message:

Fix a serious code pessimization problem.  If an inlined function has a single
return, clone the 'ret' BB code into the block AFTER the inlined call, not the
other way around.


---
Diffs of the changes:  (+6 -5)

Index: llvm/lib/Transforms/Utils/InlineFunction.cpp
diff -u llvm/lib/Transforms/Utils/InlineFunction.cpp:1.25 llvm/lib/Transforms/Utils/InlineFunction.cpp:1.26
--- llvm/lib/Transforms/Utils/InlineFunction.cpp:1.25	Fri Apr 16 00:17:59 2004
+++ llvm/lib/Transforms/Utils/InlineFunction.cpp	Tue Jul 20 00:45:24 2004
@@ -304,14 +304,15 @@
     // Splice the code from the return block into the block that it will return
     // to, which contains the code that was after the call.
     BasicBlock *ReturnBB = Returns[0]->getParent();
-    ReturnBB->getInstList().splice(Returns[0], AfterCallBB->getInstList());
+    AfterCallBB->getInstList().splice(AfterCallBB->begin(),
+                                      ReturnBB->getInstList());
 
-    // Update PHI nodes that use the AfterCallBB to use the ReturnBB.
-    AfterCallBB->replaceAllUsesWith(ReturnBB);
+    // Update PHI nodes that use the ReturnBB to use the AfterCallBB.
+    ReturnBB->replaceAllUsesWith(AfterCallBB);
       
-    // Delete the return instruction now and empty AfterCallBB now.
+    // Delete the return instruction now and empty ReturnBB now.
     Returns[0]->getParent()->getInstList().erase(Returns[0]);
-    Caller->getBasicBlockList().erase(AfterCallBB);
+    Caller->getBasicBlockList().erase(ReturnBB);
   }
     
   // Since we are now done with the Call/Invoke, we can delete it.





More information about the llvm-commits mailing list