[llvm] [DirectX] Convert private global variables to internal linkage during Finalize Linkage pass (PR #146406)
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 2 10:57:03 PDT 2025
================
@@ -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;
+ }
----------------
bogner wrote:
Should we be removing these if `GV.use_empty()` to match what we do with functions? Alternatively, if we don't expect to ever get here with unused private globals, can we `assert(!GV.use_empty())` here? Or is it okay/expected for us to leave unused internal variables around?
https://github.com/llvm/llvm-project/pull/146406
More information about the llvm-commits
mailing list