-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[DirectX] Convert private global variables to internal linkage during Finalize Linkage pass #146406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,16 @@ | |
using namespace llvm; | ||
|
||
static bool finalizeLinkage(Module &M) { | ||
bool MadeChange = false; | ||
|
||
// Convert private global variables to internal linkage. | ||
for (GlobalVariable &GV : M.globals()) { | ||
if (GV.hasPrivateLinkage()) { | ||
GV.setLinkage(GlobalValue::InternalLinkage); | ||
MadeChange = true; | ||
} | ||
Comment on lines
+25
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we be removing these if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thats the solution we worked for this ticket #139023. My understanding was though we didn't want to blanket do this because of external linkage. so, I suppose we could do something like if(GV.use_empty() && !GV.hasExtenalLinkage())
ToErase.push_back(&G); |
||
} | ||
|
||
SmallVector<Function *> Funcs; | ||
|
||
// Collect non-entry and non-exported functions to set to internal linkage. | ||
|
@@ -32,13 +42,17 @@ static bool finalizeLinkage(Module &M) { | |
} | ||
|
||
for (Function *F : Funcs) { | ||
if (F->getLinkage() == GlobalValue::ExternalLinkage) | ||
if (F->getLinkage() == GlobalValue::ExternalLinkage) { | ||
F->setLinkage(GlobalValue::InternalLinkage); | ||
if (F->isDefTriviallyDead()) | ||
MadeChange = true; | ||
} | ||
if (F->isDefTriviallyDead()) { | ||
M.getFunctionList().erase(F); | ||
MadeChange = true; | ||
} | ||
} | ||
|
||
return false; | ||
return MadeChange; | ||
} | ||
|
||
PreservedAnalyses DXILFinalizeLinkage::run(Module &M, | ||
|
Uh oh!
There was an error while loading. Please reload this page.