[llvm-commits] CVS: llvm/lib/Transforms/IPO/Internalize.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri Nov 8 14:35:10 PST 2002
Changes in directory llvm/lib/Transforms/IPO:
Internalize.cpp updated: 1.11 -> 1.12
---
Log message:
Use the new getMainFunction() method to efficiently locate main
---
Diffs of the changes:
Index: llvm/lib/Transforms/IPO/Internalize.cpp
diff -u llvm/lib/Transforms/IPO/Internalize.cpp:1.11 llvm/lib/Transforms/IPO/Internalize.cpp:1.12
--- llvm/lib/Transforms/IPO/Internalize.cpp:1.11 Mon Oct 7 13:34:32 2002
+++ llvm/lib/Transforms/IPO/Internalize.cpp Fri Nov 8 14:34:21 2002
@@ -17,21 +17,16 @@
class InternalizePass : public Pass {
virtual bool run(Module &M) {
- bool FoundMain = false; // Look for a function named main...
- for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
- if (I->getName() == "main" && !I->isExternal() &&
- I->hasExternalLinkage()) {
- FoundMain = true;
- break;
- }
-
- if (!FoundMain) return false; // No main found, must be a library...
+ Function *MainFunc = M.getMainFunction();
+
+ if (MainFunc == 0 || MainFunc->isExternal())
+ return false; // No main found, must be a library...
bool Changed = false;
// Found a main function, mark all functions not named main as internal.
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
- if (I->getName() != "main" && // Leave the main function external
+ if (&*I != MainFunc && // Leave the main function external
!I->isExternal() && // Function must be defined here
!I->hasInternalLinkage()) { // Can't already have internal linkage
I->setInternalLinkage(true);
More information about the llvm-commits
mailing list