mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-04 05:31:06 +00:00
Use the new getMainFunction() method to efficiently locate main
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4630 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a9a93f3777
commit
93fbd733e7
@ -17,21 +17,16 @@ namespace {
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user