Be careful not to make "external" function internal

llvm-svn: 2363
This commit is contained in:
Chris Lattner 2002-04-28 05:48:34 +00:00
parent 1b94c007dc
commit ee2e78b86c
1 changed files with 3 additions and 2 deletions

View File

@ -15,7 +15,7 @@ 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") {
if ((*I)->getName() == "main" && !(*I)->isExternal()) {
FoundMain = true;
break;
}
@ -26,7 +26,8 @@ class InternalizePass : public Pass {
// 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)->getName() != "main" && // Leave the main function external
!(*I)->isExternal()) // Function must be defined here
(*I)->setInternalLinkage(Changed = true);
return Changed;