[llvm] 454cc36 - [AArch64] Relax binary format switch in AArch64MCInstLower::LowerSymbolOperand to allow non-Darwin Mach-O files (#66011)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 14 11:12:34 PDT 2023
Author: Kuba (Brecka) Mracek
Date: 2023-09-14T11:12:30-07:00
New Revision: 454cc36630296262cdb6360b60f90a64a97f7f1a
URL: https://github.com/llvm/llvm-project/commit/454cc36630296262cdb6360b60f90a64a97f7f1a
DIFF: https://github.com/llvm/llvm-project/commit/454cc36630296262cdb6360b60f90a64a97f7f1a.diff
LOG: [AArch64] Relax binary format switch in AArch64MCInstLower::LowerSymbolOperand to allow non-Darwin Mach-O files (#66011)
Trying to use a arm64-apple-none-macho target triple today crashes with
an assertion, this patch fixes that.
Added:
llvm/test/CodeGen/AArch64/macho-none.ll
Modified:
llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
llvm/lib/Target/AArch64/AArch64MCInstLower.h
Removed:
################################################################################
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..b83f48725552723
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/macho-none.ll
@@ -0,0 +1,16 @@
+; RUN: llc -mtriple=arm64-apple-none-elf %s -o - | FileCheck %s --check-prefix CHECK-ELF
+; RUN: llc -mtriple=arm64-apple-none-macho %s -o - | FileCheck %s --check-prefix CHECK-MACHO
+
+ at var = global i8 0
+
+define i8 @foo() {
+ %x = load i8, ptr @var
+
+ ; CHECK-ELF: adrp x{{[0-9]+}}, :got:var
+ ; CHECK-ELF: ldr x{{[0-9]+}}, [x{{[0-9]+}}, :got_lo12:var]
+
+ ; CHECK-MACHO: adrp x{{[0-9]+}}, _var at PAGE
+ ; CHECK-MACHO: ldrb w{{[0-9]+}}, [x{{[0-9]+}}, _var at PAGEOFF]
+
+ ret i8 %x
+}
More information about the llvm-commits
mailing list