[PATCH] D85126: AArch64: use a constpool for blockaddress(...) on MachO
Tim Northover via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 6 06:39:27 PDT 2020
t.p.northover updated this revision to Diff 283594.
t.p.northover added a comment.
Ahmed pointed out that `getAddr` already results in a `MOVaddrBA` eventually so the ISelLowering change was pointless.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85126/new/
https://reviews.llvm.org/D85126
Files:
llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
llvm/test/CodeGen/AArch64/arm64-blockaddress.ll
llvm/test/CodeGen/AArch64/arm64_32.ll
Index: llvm/test/CodeGen/AArch64/arm64_32.ll
===================================================================
--- llvm/test/CodeGen/AArch64/arm64_32.ll
+++ llvm/test/CodeGen/AArch64/arm64_32.ll
@@ -450,8 +450,8 @@
define i8* @test_blockaddress() {
; CHECK-LABEL: test_blockaddress:
; CHECK: [[BLOCK:Ltmp[0-9]+]]:
-; CHECK: adrp [[PAGE:x[0-9]+]], [[BLOCK]]@PAGE
-; CHECK: add x0, [[PAGE]], [[BLOCK]]@PAGEOFF
+; CHECK: adrp x[[PAGE:[0-9]+]], lCPI{{[0-9]+_[0-9]+}}@PAGE
+; CHECK: ldr x0, [x[[PAGE]], lCPI{{[0-9]+_[0-9]+}}@PAGEOFF]
br label %dest
dest:
ret i8* blockaddress(@test_blockaddress, %dest)
Index: llvm/test/CodeGen/AArch64/arm64-blockaddress.ll
===================================================================
--- llvm/test/CodeGen/AArch64/arm64-blockaddress.ll
+++ llvm/test/CodeGen/AArch64/arm64-blockaddress.ll
@@ -1,4 +1,5 @@
-; RUN: llc < %s -mtriple=arm64-apple-ios | FileCheck %s
+; RUN: llc < %s -mtriple=arm64-apple-ios | FileCheck %s --check-prefix=CHECK-IOS
+; RUN: llc < %s -mtriple=arm64-apple-ios -global-isel | FileCheck %s --check-prefix=CHECK-IOS
; RUN: llc < %s -mtriple=arm64-linux-gnu | FileCheck %s --check-prefix=CHECK-LINUX
; RUN: llc < %s -mtriple=arm64-linux-gnu -code-model=large| FileCheck %s --check-prefix=CHECK-LARGE
@@ -6,9 +7,11 @@
define i64 @t() nounwind ssp {
entry:
-; CHECK-LABEL: t:
-; CHECK: adrp [[REG:x[0-9]+]], Ltmp0 at PAGE
-; CHECK: add {{x[0-9]+}}, [[REG]], Ltmp0 at PAGEOFF
+; CHECK-IOS: lCPI0_0:
+; CHECK-IOS: .quad Ltmp0
+; CHECK-IOS-LABEL: _t:
+; CHECK-IOS: adrp x[[TMP:[0-9]+]], lCPI0_0 at PAGE
+; CHECK-IOS: ldr {{x[0-9]+}}, [x[[TMP]], lCPI0_0 at PAGEOFF]
; CHECK-LINUX-LABEL: t:
; CHECK-LINUX: adrp [[REG:x[0-9]+]], .Ltmp0
Index: llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
+++ llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
@@ -23,6 +23,7 @@
#include "llvm/ADT/Triple.h"
#include "llvm/CodeGen/LivePhysRegs.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
+#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
@@ -835,11 +836,36 @@
MI.eraseFromParent();
return true;
}
+ case AArch64::MOVaddrBA: {
+ MachineFunction &MF = *MI.getParent()->getParent();
+ if (MF.getSubtarget<AArch64Subtarget>().isTargetMachO()) {
+ // blockaddress expressions have to come from a constant pool because the
+ // largest addend (and hence offset within a function) allowed for ADRP is
+ // only 8MB.
+ const BlockAddress *BA = MI.getOperand(1).getBlockAddress();
+ assert(MI.getOperand(1).getOffset() == 0 && "unexpected offset");
+
+ MachineConstantPool *MCP = MF.getConstantPool();
+ unsigned CPIdx = MCP->getConstantPoolIndex(BA, Align(8));
+ Register DstReg = MI.getOperand(0).getReg();
+ auto MIB1 =
+ BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(AArch64::ADRP), DstReg)
+ .addConstantPoolIndex(CPIdx, 0, AArch64II::MO_PAGE);
+ auto MIB2 = BuildMI(MBB, MBBI, MI.getDebugLoc(),
+ TII->get(AArch64::LDRXui), DstReg)
+ .addUse(DstReg)
+ .addConstantPoolIndex(
+ CPIdx, 0, AArch64II::MO_PAGEOFF | AArch64II::MO_NC);
+ transferImpOps(MI, MIB1, MIB2);
+ MI.eraseFromParent();
+ return true;
+ }
+ }
+ LLVM_FALLTHROUGH;
case AArch64::MOVaddr:
case AArch64::MOVaddrJT:
case AArch64::MOVaddrCP:
- case AArch64::MOVaddrBA:
case AArch64::MOVaddrTLS:
case AArch64::MOVaddrEXT: {
// Expand into ADRP + ADD.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85126.283594.patch
Type: text/x-patch
Size: 3754 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200806/d01337ea/attachment.bin>
More information about the llvm-commits
mailing list