[llvm-commits] CVS: llvm/lib/Transforms/FunctionInlining.cpp
Chris Lattner
lattner at apoc.cs.uiuc.edu
Sun Sep 22 13:42:01 PDT 2002
Changes in directory llvm/lib/Transforms:
FunctionInlining.cpp updated: 1.35 -> 1.36
---
Log message:
Don't insert a PHI node to merge "returns" from an inlined function if there
is only a single return from the function!
---
Diffs of the changes:
Index: llvm/lib/Transforms/FunctionInlining.cpp
diff -u llvm/lib/Transforms/FunctionInlining.cpp:1.35 llvm/lib/Transforms/FunctionInlining.cpp:1.36
--- llvm/lib/Transforms/FunctionInlining.cpp:1.35 Mon Sep 16 17:30:20 2002
+++ llvm/lib/Transforms/FunctionInlining.cpp Sun Sep 22 13:41:25 2002
@@ -190,7 +190,18 @@
RemapInstruction(II, ValueMap);
}
- if (PHI) RemapInstruction(PHI, ValueMap); // Fix the PHI node also...
+ if (PHI) {
+ RemapInstruction(PHI, ValueMap); // Fix the PHI node also...
+
+ // Check to see if the PHI node only has one argument. This is a common
+ // case resulting from there only being a single return instruction in the
+ // function call. Because this is so common, eliminate the PHI node.
+ //
+ if (PHI->getNumIncomingValues() == 1) {
+ PHI->replaceAllUsesWith(PHI->getIncomingValue(0));
+ PHI->getParent()->getInstList().erase(PHI);
+ }
+ }
// Change the branch that used to go to NewBB to branch to the first basic
// block of the inlined function.
More information about the llvm-commits
mailing list