Skip to content

Commit 6a3aedc

Browse files
committed
fix switch.table.* bug - convert private global variables to internal linkage
1 parent 01d0171 commit 6a3aedc

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

llvm/lib/Target/DirectX/DXILFinalizeLinkage.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@
1818
using namespace llvm;
1919

2020
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+
2131
SmallVector<Function *> Funcs;
2232

2333
// Collect non-entry and non-exported functions to set to internal linkage.
@@ -32,13 +42,17 @@ static bool finalizeLinkage(Module &M) {
3242
}
3343

3444
for (Function *F : Funcs) {
35-
if (F->getLinkage() == GlobalValue::ExternalLinkage)
45+
if (F->getLinkage() == GlobalValue::ExternalLinkage) {
3646
F->setLinkage(GlobalValue::InternalLinkage);
37-
if (F->isDefTriviallyDead())
47+
MadeChange = true;
48+
}
49+
if (F->isDefTriviallyDead()) {
3850
M.getFunctionList().erase(F);
51+
MadeChange = true;
52+
}
3953
}
4054

41-
return false;
55+
return MadeChange;
4256
}
4357

4458
PreservedAnalyses DXILFinalizeLinkage::run(Module &M,

0 commit comments

Comments
 (0)