There is no PIC support for -mcmodel=large (https://github.com/ARM-software/abi-aa/blob/main/sysvabi64/sysvabi64.rst) and Clang recently rejects -mcmodel= with PIC (#70262). The current backend code assumes that the large code model is non-PIC. This patch adds `!getTargetMachine().isPositionIndependent()` conditions to clarify that the support is non-PIC only. In addition, add some tests as change detectors in case PIC large code model is supported in the future. If other front-ends/JITs use the large code model with PIC, they will get small code model code sequence, instead of potentially-incorrect MOVZ/MOVK sequence, which is only suitable for non-PIC. The sequence will cause text relocations using ELF linkers. (The small code model code sequence is usually sufficient as ADRP+ADD or ADRP+LDR targets [-2**32,2**32), which has a doubled range of x86-64 R_X86_64_REX_GOTPCRELX/R_X86_64_PC32 [-2**32,2**32).)
35 lines
1.5 KiB
LLVM
35 lines
1.5 KiB
LLVM
; RUN: llc -mtriple=aarch64-none-linux-gnu -aarch64-enable-atomic-cfg-tidy=0 -verify-machineinstrs < %s | FileCheck %s
|
|
; RUN: llc -code-model=large -mtriple=aarch64-none-linux-gnu -aarch64-enable-atomic-cfg-tidy=0 -verify-machineinstrs < %s | FileCheck --check-prefix=CHECK-LARGE %s
|
|
; RUN: llc -code-model=large -relocation-model=pic -mtriple=aarch64-none-linux-gnu -aarch64-enable-atomic-cfg-tidy=0 < %s | FileCheck %s
|
|
; RUN: llc -code-model=tiny -mtriple=aarch64-none-elf -aarch64-enable-atomic-cfg-tidy=0 -verify-machineinstrs < %s | FileCheck --check-prefix=CHECK-TINY %s
|
|
|
|
@addr = global ptr null
|
|
|
|
define void @test_blockaddress() {
|
|
; CHECK-LABEL: test_blockaddress:
|
|
store volatile ptr blockaddress(@test_blockaddress, %block), ptr @addr
|
|
%val = load volatile ptr, ptr @addr
|
|
indirectbr ptr %val, [label %block]
|
|
; CHECK: adrp [[DEST_HI:x[0-9]+]], [[DEST_LBL:.Ltmp[0-9]+]]
|
|
; CHECK: add [[DEST:x[0-9]+]], [[DEST_HI]], {{#?}}:lo12:[[DEST_LBL]]
|
|
; CHECK: str [[DEST]],
|
|
; CHECK: ldr [[NEWDEST:x[0-9]+]]
|
|
; CHECK: br [[NEWDEST]]
|
|
|
|
; CHECK-LARGE: movz [[ADDR_REG:x[0-9]+]], #:abs_g0_nc:[[DEST_LBL:.Ltmp[0-9]+]]
|
|
; CHECK-LARGE: movk [[ADDR_REG]], #:abs_g1_nc:[[DEST_LBL]]
|
|
; CHECK-LARGE: movk [[ADDR_REG]], #:abs_g2_nc:[[DEST_LBL]]
|
|
; CHECK-LARGE: movk [[ADDR_REG]], #:abs_g3:[[DEST_LBL]]
|
|
; CHECK-LARGE: str [[ADDR_REG]],
|
|
; CHECK-LARGE: ldr [[NEWDEST:x[0-9]+]]
|
|
; CHECK-LARGE: br [[NEWDEST]]
|
|
|
|
; CHECK-TINY: adr [[DEST:x[0-9]+]], {{.Ltmp[0-9]+}}
|
|
; CHECK-TINY: str [[DEST]],
|
|
; CHECK-TINY: ldr [[NEWDEST:x[0-9]+]]
|
|
; CHECK-TINY: br [[NEWDEST]]
|
|
|
|
block:
|
|
ret void
|
|
}
|