[llvm-branch-commits] [lld] release/21.x: [LLD][COFF] Set isUsedInRegularObj for target symbols in resolveAlternateNames (#154837) (PR #154928)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Aug 22 04:12:35 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lld-coff
Author: None (llvmbot)
<details>
<summary>Changes</summary>
Backport a6fcd1a6632a57e1b670dd607dac97ff3bd2d33a
Requested by: @<!-- -->cjacek
---
Full diff: https://github.com/llvm/llvm-project/pull/154928.diff
2 Files Affected:
- (modified) lld/COFF/SymbolTable.cpp (+1)
- (added) lld/test/COFF/alternatename-lto.ll (+25)
``````````diff
diff --git a/lld/COFF/SymbolTable.cpp b/lld/COFF/SymbolTable.cpp
index 189e75dfc3ff5..d15e0c24410c6 100644
--- a/lld/COFF/SymbolTable.cpp
+++ b/lld/COFF/SymbolTable.cpp
@@ -1374,6 +1374,7 @@ void SymbolTable::resolveAlternateNames() {
auto toUndef = dyn_cast<Undefined>(toSym);
if (toUndef && (!toUndef->weakAlias || toUndef->isAntiDep))
continue;
+ toSym->isUsedInRegularObj = true;
if (toSym->isLazy())
forceLazy(toSym);
u->setWeakAlias(toSym);
diff --git a/lld/test/COFF/alternatename-lto.ll b/lld/test/COFF/alternatename-lto.ll
new file mode 100644
index 0000000000000..c3666cd3501df
--- /dev/null
+++ b/lld/test/COFF/alternatename-lto.ll
@@ -0,0 +1,25 @@
+; REQUIRES: x86
+; RUN: mkdir -p %t.dir
+; RUN: llvm-as -o %t.obj %s
+; RUN: lld-link -out:%t.dll -dll -noentry %t.obj -export:test
+
+target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-windows-msvc19.33.0"
+
+$alt = comdat any
+
+ at alt = weak_odr dso_local global i32 0, comdat, align 4
+ at ext = external dso_local global i32, align 4
+
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local i32 @test() #0 {
+entry:
+ %0 = load i32, ptr @ext, align 4
+ ret i32 %0
+}
+
+attributes #0 = { noinline nounwind optnone uwtable }
+
+!llvm.linker.options = !{!0}
+
+!0 = !{!"/alternatename:ext=alt"}
``````````
</details>
https://github.com/llvm/llvm-project/pull/154928
More information about the llvm-branch-commits
mailing list