diff options
author | Chris Lattner <sabre@nondot.org> | 2002-09-22 18:41:25 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-09-22 18:41:25 +0000 |
commit | bdccb0097061e05b506592c25b3b5e9e0692c950 (patch) | |
tree | db57c37c140bf49c9743121c183a5f05279b6214 | |
parent | 172b648cd4335d654edb432238d92547ffa0e362 (diff) |
Don't insert a PHI node to merge "returns" from an inlined function if there
is only a single return from the function!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3878 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/IPO/InlineSimple.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index d88a923e22..41f849a798 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -190,7 +190,18 @@ bool InlineFunction(CallInst *CI) { 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. |