File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
test/Transforms/Internalize Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 26
26
#include < set>
27
27
using namespace llvm ;
28
28
29
+ STATISTIC (NumAliases , " Number of aliases internalized" );
29
30
STATISTIC (NumFunctions, " Number of functions internalized" );
30
31
STATISTIC (NumGlobals , " Number of global vars internalized" );
31
32
@@ -158,6 +159,17 @@ bool InternalizePass::runOnModule(Module &M) {
158
159
DOUT << " Internalized gvar " << I->getName () << " \n " ;
159
160
}
160
161
162
+ // Mark all aliases that are not in the api as internal as well.
163
+ for (Module::alias_iterator I = M.alias_begin (), E = M.alias_end ();
164
+ I != E; ++I)
165
+ if (!I->isDeclaration () && !I->hasInternalLinkage () &&
166
+ !ExternalNames.count (I->getName ())) {
167
+ I->setLinkage (GlobalValue::InternalLinkage);
168
+ Changed = true ;
169
+ ++NumAliases;
170
+ DOUT << " Internalized alias " << I->getName () << " \n " ;
171
+ }
172
+
161
173
return Changed;
162
174
}
163
175
Original file line number Diff line number Diff line change
1
+ ; RUN: llvm-as < %s | opt -internalize | llvm-dis | grep internal | count 3
2
+
3
+ @A = global i32 0
4
+ @B = alias i32* @A
5
+ @C = alias i32* @B
6
+
7
+ define i32 @main () {
8
+ %tmp = load i32* @C
9
+ ret i32 %tmp
10
+ }
You can’t perform that action at this time.
0 commit comments