Skip to content

Commit ab81227

Browse files
committed
[AArch64] Relax binary format switch in AArch64MCInstLower::LowerSymbolOperand to allow non-Darwin Mach-O files
1 parent a362e71 commit ab81227

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

llvm/lib/Target/AArch64/AArch64MCInstLower.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ AArch64MCInstLower::GetExternalSymbolSymbol(const MachineOperand &MO) const {
142142
return Printer.GetExternalSymbolSymbol(MO.getSymbolName());
143143
}
144144

145-
MCOperand AArch64MCInstLower::lowerSymbolOperandDarwin(const MachineOperand &MO,
146-
MCSymbol *Sym) const {
145+
MCOperand AArch64MCInstLower::lowerSymbolOperandMachO(const MachineOperand &MO,
146+
MCSymbol *Sym) const {
147147
// FIXME: We would like an efficient form for this, so we don't have to do a
148148
// lot of extra uniquing.
149149
MCSymbolRefExpr::VariantKind RefKind = MCSymbolRefExpr::VK_None;
@@ -312,8 +312,8 @@ MCOperand AArch64MCInstLower::lowerSymbolOperandCOFF(const MachineOperand &MO,
312312

313313
MCOperand AArch64MCInstLower::LowerSymbolOperand(const MachineOperand &MO,
314314
MCSymbol *Sym) const {
315-
if (Printer.TM.getTargetTriple().isOSDarwin())
316-
return lowerSymbolOperandDarwin(MO, Sym);
315+
if (Printer.TM.getTargetTriple().isOSBinFormatMachO())
316+
return lowerSymbolOperandMachO(MO, Sym);
317317
if (Printer.TM.getTargetTriple().isOSBinFormatCOFF())
318318
return lowerSymbolOperandCOFF(MO, Sym);
319319

llvm/lib/Target/AArch64/AArch64MCInstLower.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ class LLVM_LIBRARY_VISIBILITY AArch64MCInstLower {
3434
bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp) const;
3535
void Lower(const MachineInstr *MI, MCInst &OutMI) const;
3636

37-
MCOperand lowerSymbolOperandDarwin(const MachineOperand &MO,
38-
MCSymbol *Sym) const;
37+
MCOperand lowerSymbolOperandMachO(const MachineOperand &MO,
38+
MCSymbol *Sym) const;
3939
MCOperand lowerSymbolOperandELF(const MachineOperand &MO,
4040
MCSymbol *Sym) const;
4141
MCOperand lowerSymbolOperandCOFF(const MachineOperand &MO,
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
; RUN: llc -mtriple=arm64-apple-none-elf %s -o - | FileCheck %s --check-prefix CHECK-ELF
2+
; RUN: llc -mtriple=arm64-apple-none-macho %s -o - | FileCheck %s --check-prefix CHECK-MACHO
3+
4+
@var = global i8 0
5+
6+
define i8 @foo() {
7+
%x = load i8, ptr @var
8+
9+
; CHECK-ELF: adrp x{{[0-9]+}}, :got:var
10+
; CHECK-ELF: ldr x{{[0-9]+}}, [x{{[0-9]+}}, :got_lo12:var]
11+
12+
; CHECK-MACHO: adrp x{{[0-9]+}}, _var@PAGE
13+
; CHECK-MACHO: ldrb w{{[0-9]+}}, [x{{[0-9]+}}, _var@PAGEOFF]
14+
15+
ret i8 %x
16+
}

0 commit comments

Comments
 (0)