-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[LLD][COFF] Set isUsedInRegularObj for target symbols in resolveAlternateNames #154837
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
Conversation
…nateNames Fixes: 154595 Prior to commit bbc8346, this flag was set by insert() from addUndefined(). Set it explicitly now.
@llvm/pr-subscribers-lld Author: Jacek Caban (cjacek) ChangesFixes: 154595 Prior to commit bbc8346, this flag was set by Full diff: https://github.com/llvm/llvm-project/pull/154837.diff 2 Files Affected:
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"}
|
@llvm/pr-subscribers-platform-windows Author: Jacek Caban (cjacek) ChangesFixes: 154595 Prior to commit bbc8346, this flag was set by Full diff: https://github.com/llvm/llvm-project/pull/154837.diff 2 Files Affected:
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"}
|
@llvm/pr-subscribers-lld-coff Author: Jacek Caban (cjacek) ChangesFixes: 154595 Prior to commit bbc8346, this flag was set by Full diff: https://github.com/llvm/llvm-project/pull/154837.diff 2 Files Affected:
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"}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/cherry-pick a6fcd1a |
/pull-request #154928 |
…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)
Fixes: #154595
Prior to commit bbc8346, this flag was set by
insert()
fromaddUndefined()
. Set it explicitly now.