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

Chris Lattner lattner at cs.uiuc.edu
Wed May 12 11:26:03 PDT 2004


Changes in directory llvm/lib/Transforms/Utils:

CodeExtractor.cpp updated: 1.22 -> 1.23

---
Log message:

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.


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

Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
diff -u llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.22 llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.23
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.22	Wed May 12 11:07:41 2004
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp	Wed May 12 11:26:18 2004
@@ -226,6 +226,12 @@
   } // 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 @@
   // 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.





More information about the llvm-commits mailing list