[llvm] [AArch64] Relax binary format switch in AArch64MCInstLower::LowerSymbolOperand to allow non-Darwin Mach-O files (PR #66011)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 11 14:21:29 PDT 2023
llvmbot wrote:
@llvm/pr-subscribers-backend-aarch64
<details>
<summary>Changes</summary>
Trying to use a arm64-apple-none-macho target triple today crashes with an assertion, this patch fixes that.
--
Full diff: https://github.com/llvm/llvm-project/pull/66011.diff
3 Files Affected:
- (modified) llvm/lib/Target/AArch64/AArch64MCInstLower.cpp (+4-4)
- (modified) llvm/lib/Target/AArch64/AArch64MCInstLower.h (+2-2)
- (added) llvm/test/CodeGen/AArch64/macho-none.ll (+9)
<pre>
diff --git a/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp b/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
index 69a66f4335c1cd2..59969f9dc31ce36 100644
--- a/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
+++ b/llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
@@ -100,8 +100,8 @@ AArch64MCInstLower::GetExternalSymbolSymbol(const MachineOperand &MO) const {
return Printer.GetExternalSymbolSymbol(MO.getSymbolName());
}
-MCOperand AArch64MCInstLower::lowerSymbolOperandDarwin(const MachineOperand &MO,
- MCSymbol *Sym) const {
+MCOperand AArch64MCInstLower::lowerSymbolOperandMachO(const MachineOperand &MO,
+ MCSymbol *Sym) const {
// FIXME: We would like an efficient form for this, so we don't have to do a
// lot of extra uniquing.
MCSymbolRefExpr::VariantKind RefKind = MCSymbolRefExpr::VK_None;
@@ -270,8 +270,8 @@ MCOperand AArch64MCInstLower::lowerSymbolOperandCOFF(const MachineOperand &MO,
MCOperand AArch64MCInstLower::LowerSymbolOperand(const MachineOperand &MO,
MCSymbol *Sym) const {
- if (Printer.TM.getTargetTriple().isOSDarwin())
- return lowerSymbolOperandDarwin(MO, Sym);
+ if (Printer.TM.getTargetTriple().isOSBinFormatMachO())
+ return lowerSymbolOperandMachO(MO, Sym);
if (Printer.TM.getTargetTriple().isOSBinFormatCOFF())
return lowerSymbolOperandCOFF(MO, Sym);
diff --git a/llvm/lib/Target/AArch64/AArch64MCInstLower.h b/llvm/lib/Target/AArch64/AArch64MCInstLower.h
index 8b6abc5c1f23c7c..e4f8a1bc1a31735 100644
--- a/llvm/lib/Target/AArch64/AArch64MCInstLower.h
+++ b/llvm/lib/Target/AArch64/AArch64MCInstLower.h
@@ -34,8 +34,8 @@ class LLVM_LIBRARY_VISIBILITY AArch64MCInstLower {
bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp) const;
void Lower(const MachineInstr *MI, MCInst &OutMI) const;
- MCOperand lowerSymbolOperandDarwin(const MachineOperand &MO,
- MCSymbol *Sym) const;
+ MCOperand lowerSymbolOperandMachO(const MachineOperand &MO,
+ MCSymbol *Sym) const;
MCOperand lowerSymbolOperandELF(const MachineOperand &MO,
MCSymbol *Sym) const;
MCOperand lowerSymbolOperandCOFF(const MachineOperand &MO,
diff --git a/llvm/test/CodeGen/AArch64/macho-none.ll b/llvm/test/CodeGen/AArch64/macho-none.ll
new file mode 100644
index 000000000000000..81f7bf473aaf6d6
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/macho-none.ll
@@ -0,0 +1,9 @@
+; RUN: llc -mtriple=arm64-apple-none-elf %s -o -
+; RUN: llc -mtriple=arm64-apple-none-macho %s -o -
+
+ at var = global i8 0
+
+define i8 @foo() {
+ %x = load i8, ptr @var
+ ret i8 %x
+}
</pre>
</details>
https://github.com/llvm/llvm-project/pull/66011
More information about the llvm-commits
mailing list