@@ -73,7 +73,7 @@ InternalizePass::InternalizePass(bool AllButMain)
73
73
ExternalNames.insert (APIList.begin (), APIList.end ());
74
74
}
75
75
76
- InternalizePass::InternalizePass (const std::vector<const char *>&exportList)
76
+ InternalizePass::InternalizePass (const std::vector<const char *>&exportList)
77
77
: ModulePass(&ID), AllButMain(false ){
78
78
for (std::vector<const char *>::const_iterator itr = exportList.begin ();
79
79
itr != exportList.end (); itr++) {
@@ -85,7 +85,7 @@ void InternalizePass::LoadFile(const char *Filename) {
85
85
// Load the APIFile...
86
86
std::ifstream In (Filename);
87
87
if (!In.good ()) {
88
- cerr << " WARNING: Internalize couldn't load file '" << Filename
88
+ cerr << " WARNING: Internalize couldn't load file '" << Filename
89
89
<< " '! Continuing as if it's empty.\n " ;
90
90
return ; // Just continue as if the file were empty
91
91
}
@@ -104,21 +104,21 @@ bool InternalizePass::runOnModule(Module &M) {
104
104
if (ExternalNames.empty ()) {
105
105
// Return if we're not in 'all but main' mode and have no external api
106
106
if (!AllButMain)
107
- return false ;
107
+ return false ;
108
108
// If no list or file of symbols was specified, check to see if there is a
109
109
// "main" symbol defined in the module. If so, use it, otherwise do not
110
110
// internalize the module, it must be a library or something.
111
111
//
112
112
Function *MainFunc = M.getFunction (" main" );
113
113
if (MainFunc == 0 || MainFunc->isDeclaration ())
114
114
return false ; // No main found, must be a library...
115
-
115
+
116
116
// Preserve main, internalize all else.
117
117
ExternalNames.insert (MainFunc->getName ());
118
118
}
119
-
119
+
120
120
bool Changed = false ;
121
-
121
+
122
122
// Mark all functions not in the api as internal.
123
123
for (Module::iterator I = M.begin (), E = M.end (); I != E; ++I)
124
124
if (!I->isDeclaration () && // Function must be defined here
@@ -131,11 +131,11 @@ bool InternalizePass::runOnModule(Module &M) {
131
131
++NumFunctions;
132
132
DOUT << " Internalizing func " << I->getName () << " \n " ;
133
133
}
134
-
134
+
135
135
// Never internalize the llvm.used symbol. It is used to implement
136
136
// attribute((used)).
137
137
ExternalNames.insert (" llvm.used" );
138
-
138
+
139
139
// Never internalize anchors used by the machine module info, else the info
140
140
// won't find them. (see MachineModuleInfo.)
141
141
ExternalNames.insert (" llvm.dbg.compile_units" );
@@ -145,7 +145,7 @@ bool InternalizePass::runOnModule(Module &M) {
145
145
ExternalNames.insert (" llvm.global_dtors" );
146
146
ExternalNames.insert (" llvm.noinline" );
147
147
ExternalNames.insert (" llvm.global.annotations" );
148
-
148
+
149
149
// Mark all global variables with initializers that are not in the api as
150
150
// internal as well.
151
151
for (Module::global_iterator I = M.global_begin (), E = M.global_end ();
@@ -157,7 +157,7 @@ bool InternalizePass::runOnModule(Module &M) {
157
157
++NumGlobals;
158
158
DOUT << " Internalized gvar " << I->getName () << " \n " ;
159
159
}
160
-
160
+
161
161
return Changed;
162
162
}
163
163
0 commit comments