Revert "[MachO] Preserve weak linkage for aliases" - #212009
Merged
Merged
Conversation
This reverts commit 29575a3.
Member
Author
|
CC @syhhyl |
|
@llvm/pr-subscribers-llvm-mc @llvm/pr-subscribers-backend-aarch64 Author: Nathan Corbyn (cofibrant) ChangesReverts llvm/llvm-project#198148 As #212001 points out, #198148's approach to merging the linkage flags is incorrect. I propose we revert for now, build an understanding of the work required to support this properly and try again. Full diff: https://github.com/llvm/llvm-project/pull/212009.diff 3 Files Affected:
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index e544fa4d4414a..11d39fcff0ff7 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -2644,9 +2644,7 @@ void AsmPrinter::emitGlobalAlias(const Module &M, const GlobalAlias &GA) {
return;
}
- if (MAI.isMachO())
- emitLinkage(&GA, Name);
- else if (GA.hasExternalLinkage() || !MAI.getWeakRefDirective())
+ if (GA.hasExternalLinkage() || !MAI.getWeakRefDirective())
OutStreamer->emitSymbolAttribute(Name, MCSA_Global);
else if (GA.hasWeakLinkage() || GA.hasLinkOnceLinkage())
OutStreamer->emitSymbolAttribute(Name, MCSA_WeakReference);
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp
index 657f6f40fd9e9..e274d886c22d8 100644
--- a/llvm/lib/MC/MachObjectWriter.cpp
+++ b/llvm/lib/MC/MachObjectWriter.cpp
@@ -443,12 +443,7 @@ void MachObjectWriter::writeNlist(MachSymbolData &MSD, const MCAssembler &Asm) {
// The Mach-O streamer uses the lowest 16-bits of the flags for the 'desc'
// value.
bool EncodeAsAltEntry = IsAlias && OrigSymbol.isAltEntry();
- uint16_t Flags = Symbol->getEncodedFlags(EncodeAsAltEntry);
- // Preserve the aliasee's flags while adding alias-specific flags,
- // such as N_WEAK_DEF emitted by .weak_definition.
- if (IsAlias)
- Flags |= OrigSymbol.getEncodedFlags(EncodeAsAltEntry);
- W.write<uint16_t>(Flags);
+ W.write<uint16_t>(Symbol->getEncodedFlags(EncodeAsAltEntry));
if (is64Bit())
W.write<uint64_t>(Address);
else
diff --git a/llvm/test/CodeGen/AArch64/macho-weak-alias.ll b/llvm/test/CodeGen/AArch64/macho-weak-alias.ll
deleted file mode 100644
index a936cea618b38..0000000000000
--- a/llvm/test/CodeGen/AArch64/macho-weak-alias.ll
+++ /dev/null
@@ -1,17 +0,0 @@
-; RUN: llc -mtriple=aarch64-apple-macosx13.0.0 -filetype=obj %s -o %t.o
-; RUN: llvm-nm -m %t.o | FileCheck %s
-
-define internal void @foo_internal() {
- ret void
-}
-
-@foo_default = weak_odr alias void (), ptr @foo_internal
-@foo_hidden = weak_odr hidden alias void (), ptr @foo_internal
-
-define weak_odr hidden void @foo_defined() {
- ret void
-}
-
-; CHECK-DAG: weak external _foo_default
-; CHECK-DAG: weak private external _foo_hidden
-; CHECK-DAG: weak private external _foo_defined
|
This was referenced Jul 25, 2026
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/161/builds/12451 Here is the relevant piece of the build log for the reference |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reverts #198148
As #212001 points out, #198148's approach to merging the linkage flags is incorrect. I propose we revert for now, build an understanding of the work required to support this properly and try again.