Skip to content

[MC] Explicitly mark MCSymbol for MO_ExternalSymbol #108880

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

weiweichen
Copy link
Contributor

  • Mark MCSymbol for MO_ExternalSymbol to be external when created.

@llvmbot
Copy link
Member

llvmbot commented Sep 16, 2024

@llvm/pr-subscribers-lld-macho
@llvm/pr-subscribers-lld

@llvm/pr-subscribers-backend-x86

Author: weiwei chen (weiweichen)

Changes
  • Mark MCSymbol for MO_ExternalSymbol to be external when created.

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

1 Files Affected:

  • (modified) llvm/lib/Target/X86/X86MCInstLower.cpp (+5-2)
diff --git a/llvm/lib/Target/X86/X86MCInstLower.cpp b/llvm/lib/Target/X86/X86MCInstLower.cpp
index 77ddd2366e629e..949711f35aa584 100644
--- a/llvm/lib/Target/X86/X86MCInstLower.cpp
+++ b/llvm/lib/Target/X86/X86MCInstLower.cpp
@@ -350,8 +350,11 @@ MCOperand X86MCInstLower::LowerMachineOperand(const MachineInstr *MI,
     return MCOperand::createImm(MO.getImm());
   case MachineOperand::MO_MachineBasicBlock:
   case MachineOperand::MO_GlobalAddress:
-  case MachineOperand::MO_ExternalSymbol:
-    return LowerSymbolOperand(MO, GetSymbolFromOperand(MO));
+  case MachineOperand::MO_ExternalSymbol: {
+    MCSymbol *Sym = GetSymbolFromOperand(MO);
+    Sym->setExternal(true);
+    return LowerSymbolOperand(MO, Sym);
+  }
   case MachineOperand::MO_MCSymbol:
     return LowerSymbolOperand(MO, MO.getMCSymbol());
   case MachineOperand::MO_JumpTableIndex:

@weiweichen weiweichen requested a review from Mogball September 16, 2024 20:45
…eic/mark-x86-externalsymbol-mcsymbol-external
@weiweichen weiweichen requested a review from sanjoy September 17, 2024 17:15
@@ -350,8 +350,11 @@ MCOperand X86MCInstLower::LowerMachineOperand(const MachineInstr *MI,
return MCOperand::createImm(MO.getImm());
case MachineOperand::MO_MachineBasicBlock:
case MachineOperand::MO_GlobalAddress:
case MachineOperand::MO_ExternalSymbol:
return LowerSymbolOperand(MO, GetSymbolFromOperand(MO));
case MachineOperand::MO_ExternalSymbol: {
Copy link
Contributor

Choose a reason for hiding this comment

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

did you mean for MO_GlobalAddress and MO_MachineBasicBlock to also hit this branch?

Copy link
Contributor Author

@weiweichen weiweichen Sep 18, 2024

Choose a reason for hiding this comment

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

welp, no, 🤦‍♀️, thanks for pointing this out!

@weiweichen weiweichen merged commit 3d0846b into llvm:main Sep 20, 2024
8 checks passed
@mstorsjo
Copy link
Member

Wouldn't this change require a test?

Zentrik added a commit to Zentrik/llvm-project that referenced this pull request Mar 21, 2025
efriedma-quic added a commit that referenced this pull request Mar 27, 2025
efriedma-quic added a commit that referenced this pull request Mar 28, 2025
Reverts #108880 .

The patch has no regression test, no description of why the fix is
necessary, and the code is modifying MC datastructures in a way that's
forbidden in the AsmPrinter.

Fixes #132055.
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Mar 28, 2025
…l" (#133291)

Reverts llvm/llvm-project#108880 .

The patch has no regression test, no description of why the fix is
necessary, and the code is modifying MC datastructures in a way that's
forbidden in the AsmPrinter.

Fixes #132055.
swift-ci pushed a commit to swiftlang/llvm-project that referenced this pull request Mar 29, 2025
…3291)

Reverts llvm#108880 .

The patch has no regression test, no description of why the fix is
necessary, and the code is modifying MC datastructures in a way that's
forbidden in the AsmPrinter.

Fixes llvm#132055.

(cherry picked from commit cd6e959)
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request May 15, 2025
…l" (#133291)

Reverts llvm/llvm-project#108880 .

The patch has no regression test, no description of why the fix is
necessary, and the code is modifying MC datastructures in a way that's
forbidden in the AsmPrinter.

Fixes #132055.

(cherry picked from commit cd6e959)
oneseer pushed a commit to oneseer/llvm that referenced this pull request May 24, 2025
Reverts llvm/llvm-project#108880 .

The patch has no regression test, no description of why the fix is
necessary, and the code is modifying MC datastructures in a way that's
forbidden in the AsmPrinter.

Fixes #132055.

patch.cherry: true
patch.metadata.original_sha: cd6e959
patch.platforms: chromiumos
patch.version_range.from: 550362
patch.version_range.until: 570122

Change-Id: I998708a3260843e5c306edc18251835d2e2d5ce3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants