diff options
author | Chris Lattner <sabre@nondot.org> | 2004-05-12 16:26:18 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-05-12 16:26:18 +0000 |
commit | 587992721c3112c94000722941748cf46cd0bce6 (patch) | |
tree | b192073f23d487ec48434f5f363dc06255c3c9bb | |
parent | 68bee938e539d884ee89ce4dfebbad777896960e (diff) | |
download | external_llvm-587992721c3112c94000722941748cf46cd0bce6.zip external_llvm-587992721c3112c94000722941748cf46cd0bce6.tar.gz external_llvm-587992721c3112c94000722941748cf46cd0bce6.tar.bz2 |
Do not pass in the same argument to the extracted function more than once, and
give the extracted function a more useful name than just foo_code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13493 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Utils/CodeExtractor.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp index e325921..4d1093b 100644 --- a/lib/Transforms/Utils/CodeExtractor.cpp +++ b/lib/Transforms/Utils/CodeExtractor.cpp @@ -226,6 +226,12 @@ void CodeExtractor::findInputsOutputs(Values &inputs, Values &outputs) { } // for: basic blocks NumExitBlocks = ExitBlocks.size(); + + // Eliminate duplicates. + std::sort(inputs.begin(), inputs.end()); + inputs.erase(std::unique(inputs.begin(), inputs.end()), inputs.end()); + std::sort(outputs.begin(), outputs.end()); + outputs.erase(std::unique(outputs.begin(), outputs.end()), outputs.end()); } /// constructFunction - make a function based on inputs and outputs, as follows: @@ -284,7 +290,8 @@ Function *CodeExtractor::constructFunction(const Values &inputs, // Create the new function Function *newFunction = new Function(funcType, GlobalValue::InternalLinkage, - oldFunction->getName() + "_code", M); + oldFunction->getName() + "_" + + header->getName(), M); newFunction->getBasicBlockList().push_back(newRootNode); // Create an iterator to name all of the arguments we inserted. |