[llvm] [DirectX] Add GlobalDCE pass after finalize linkage pass in DirectX backend (PR #151071)

Farzon Lotfi via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 29 14:05:01 PDT 2025


================
@@ -20,13 +20,13 @@ 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()) {
+  // Convert private globals and external globals with no usage to internal
+  // linkage.
+  for (GlobalVariable &GV : M.globals())
+    if (GV.hasPrivateLinkage() || (GV.hasExternalLinkage() && GV.use_empty())) {
----------------
farzonl wrote:

Justin suggested we not do special casing of global_ctors and that GlobalDCE was a more complete solution. Hence why we closed the previous attempt at fixing this issue.

https://github.com/llvm/llvm-project/pull/151071


More information about the llvm-commits mailing list