Skip to content

Conversation

cjacek
Copy link
Contributor

@cjacek cjacek commented Aug 21, 2025

Fixes: #154595

Prior to commit bbc8346, this flag was set by insert() from addUndefined(). Set it explicitly now.

…nateNames

Fixes: 154595

Prior to commit bbc8346, this flag was set by
insert() from addUndefined(). Set it explicitly now.
@llvmbot
Copy link
Member

llvmbot commented Aug 21, 2025

@llvm/pr-subscribers-lld

Author: Jacek Caban (cjacek)

Changes

Fixes: 154595

Prior to commit bbc8346, this flag was set by insert() from addUndefined(). Set it explicitly now.


Full diff: https://github.com/llvm/llvm-project/pull/154837.diff

2 Files Affected:

  • (modified) lld/COFF/SymbolTable.cpp (+1)
  • (added) lld/test/COFF/alternatename-lto.ll (+25)
diff --git a/lld/COFF/SymbolTable.cpp b/lld/COFF/SymbolTable.cpp
index e11d2c6dac83e..0a88807c00dd5 100644
--- a/lld/COFF/SymbolTable.cpp
+++ b/lld/COFF/SymbolTable.cpp
@@ -1399,6 +1399,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
+
+@alt = weak_odr dso_local global i32 0, comdat, align 4
+@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"}

@llvmbot
Copy link
Member

llvmbot commented Aug 21, 2025

@llvm/pr-subscribers-platform-windows

Author: Jacek Caban (cjacek)

Changes

Fixes: 154595

Prior to commit bbc8346, this flag was set by insert() from addUndefined(). Set it explicitly now.


Full diff: https://github.com/llvm/llvm-project/pull/154837.diff

2 Files Affected:

  • (modified) lld/COFF/SymbolTable.cpp (+1)
  • (added) lld/test/COFF/alternatename-lto.ll (+25)
diff --git a/lld/COFF/SymbolTable.cpp b/lld/COFF/SymbolTable.cpp
index e11d2c6dac83e..0a88807c00dd5 100644
--- a/lld/COFF/SymbolTable.cpp
+++ b/lld/COFF/SymbolTable.cpp
@@ -1399,6 +1399,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
+
+@alt = weak_odr dso_local global i32 0, comdat, align 4
+@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"}

@llvmbot
Copy link
Member

llvmbot commented Aug 21, 2025

@llvm/pr-subscribers-lld-coff

Author: Jacek Caban (cjacek)

Changes

Fixes: 154595

Prior to commit bbc8346, this flag was set by insert() from addUndefined(). Set it explicitly now.


Full diff: https://github.com/llvm/llvm-project/pull/154837.diff

2 Files Affected:

  • (modified) lld/COFF/SymbolTable.cpp (+1)
  • (added) lld/test/COFF/alternatename-lto.ll (+25)
diff --git a/lld/COFF/SymbolTable.cpp b/lld/COFF/SymbolTable.cpp
index e11d2c6dac83e..0a88807c00dd5 100644
--- a/lld/COFF/SymbolTable.cpp
+++ b/lld/COFF/SymbolTable.cpp
@@ -1399,6 +1399,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
+
+@alt = weak_odr dso_local global i32 0, comdat, align 4
+@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"}

Copy link
Member

@mstorsjo mstorsjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cjacek cjacek merged commit a6fcd1a into llvm:main Aug 22, 2025
13 checks passed
@cjacek cjacek deleted the alt-name-lto branch August 22, 2025 11:05
@cjacek cjacek added this to the LLVM 21.x Release milestone Aug 22, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in LLVM Release Status Aug 22, 2025
@cjacek
Copy link
Contributor Author

cjacek commented Aug 22, 2025

/cherry-pick a6fcd1a

@llvmbot
Copy link
Member

llvmbot commented Aug 22, 2025

/pull-request #154928

@llvmbot llvmbot moved this from Needs Triage to Done in LLVM Release Status Aug 22, 2025
tru pushed a commit to llvmbot/llvm-project that referenced this pull request Aug 25, 2025
…nateNames (llvm#154837)

Fixes: llvm#154595

Prior to commit bbc8346, this flag was
set by `insert()` from `addUndefined()`. Set it explicitly now.

(cherry picked from commit a6fcd1a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

[lld] lld-link 21.1.0-rc3: undefined reference to _Avx2WmemEnabled
3 participants