File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change 18
18
using namespace llvm ;
19
19
20
20
static bool finalizeLinkage (Module &M) {
21
+ bool MadeChange = false ;
22
+
23
+ // Convert private global variables to internal linkage.
24
+ for (GlobalVariable &GV : M.globals ()) {
25
+ if (GV.hasPrivateLinkage ()) {
26
+ GV.setLinkage (GlobalValue::InternalLinkage);
27
+ MadeChange = true ;
28
+ }
29
+ }
30
+
21
31
SmallVector<Function *> Funcs;
22
32
23
33
// Collect non-entry and non-exported functions to set to internal linkage.
@@ -32,13 +42,17 @@ static bool finalizeLinkage(Module &M) {
32
42
}
33
43
34
44
for (Function *F : Funcs) {
35
- if (F->getLinkage () == GlobalValue::ExternalLinkage)
45
+ if (F->getLinkage () == GlobalValue::ExternalLinkage) {
36
46
F->setLinkage (GlobalValue::InternalLinkage);
37
- if (F->isDefTriviallyDead ())
47
+ MadeChange = true ;
48
+ }
49
+ if (F->isDefTriviallyDead ()) {
38
50
M.getFunctionList ().erase (F);
51
+ MadeChange = true ;
52
+ }
39
53
}
40
54
41
- return false ;
55
+ return MadeChange ;
42
56
}
43
57
44
58
PreservedAnalyses DXILFinalizeLinkage::run (Module &M,
You can’t perform that action at this time.
0 commit comments