llvm-for-llvmta/test/CodeGen/Thumb2/pic-load.ll

61 lines
2.7 KiB
LLVM
Raw Normal View History

2022-04-25 10:02:23 +02:00
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=thumbv7-apple-darwin9 -relocation-model=pic -o - | FileCheck %s --check-prefix=CHECK-PIC
; RUN: llc < %s -mtriple=thumbv7-apple-ios -relocation-model=pic -mcpu=swift -mattr=+no-movt | FileCheck %s --check-prefix=CHECK-NOMOVT
%struct.anon = type { void ()* }
%struct.one_atexit_routine = type { %struct.anon, i32, i8* }
@__dso_handle = external global { } ; <{ }*> [#uses=1]
@llvm.used = appending global [1 x i8*] [i8* bitcast (i32 (void ()*)* @atexit to i8*)], section "llvm.metadata" ; <[1 x i8*]*> [#uses=0]
define i32 @atexit(void ()* %func) {
; CHECK-PIC-LABEL: atexit:
; CHECK-PIC: @ %bb.0: @ %entry
; CHECK-PIC-NEXT: str lr, [sp, #-4]!
; CHECK-PIC-NEXT: sub sp, #12
; CHECK-PIC-NEXT: movw r1, :lower16:(L___dso_handle$non_lazy_ptr-(LPC0_0+4))
; CHECK-PIC-NEXT: movs r2, #0
; CHECK-PIC-NEXT: movt r1, :upper16:(L___dso_handle$non_lazy_ptr-(LPC0_0+4))
; CHECK-PIC-NEXT: strd r0, r2, [sp]
; CHECK-PIC-NEXT: LPC0_0:
; CHECK-PIC-NEXT: add r1, pc
; CHECK-PIC-NEXT: mov r0, sp
; CHECK-PIC-NEXT: ldr r1, [r1]
; CHECK-PIC-NEXT: bl _atexit_common
; CHECK-PIC-NEXT: add sp, #12
; CHECK-PIC-NEXT: ldr lr, [sp], #4
; CHECK-PIC-NEXT: bx lr
;
; CHECK-NOMOVT-LABEL: atexit:
; CHECK-NOMOVT: @ %bb.0: @ %entry
; CHECK-NOMOVT-NEXT: str lr, [sp, #-4]!
; CHECK-NOMOVT-NEXT: sub sp, #12
; CHECK-NOMOVT-NEXT: str r0, [sp]
; CHECK-NOMOVT-NEXT: movs r0, #0
; CHECK-NOMOVT-NEXT: str r0, [sp, #4]
; CHECK-NOMOVT-NEXT: ldr r0, LCPI0_0
; CHECK-NOMOVT-NEXT: LPC0_0:
; CHECK-NOMOVT-NEXT: add r0, pc
; CHECK-NOMOVT-NEXT: ldr r1, [r0]
; CHECK-NOMOVT-NEXT: mov r0, sp
; CHECK-NOMOVT-NEXT: bl _atexit_common
; CHECK-NOMOVT-NEXT: add sp, #12
; CHECK-NOMOVT-NEXT: ldr lr, [sp], #4
; CHECK-NOMOVT-NEXT: bx lr
; CHECK-NOMOVT-NEXT: .p2align 2
; CHECK-NOMOVT-NEXT: @ %bb.1:
; CHECK-NOMOVT-NEXT: .data_region
; CHECK-NOMOVT-NEXT: LCPI0_0:
; CHECK-NOMOVT-NEXT: .long L___dso_handle$non_lazy_ptr-(LPC0_0+4)
; CHECK-NOMOVT-NEXT: .end_data_region
entry:
%r = alloca %struct.one_atexit_routine, align 4 ; <%struct.one_atexit_routine*> [#uses=3]
%0 = getelementptr %struct.one_atexit_routine, %struct.one_atexit_routine* %r, i32 0, i32 0, i32 0 ; <void ()**> [#uses=1]
store void ()* %func, void ()** %0, align 4
%1 = getelementptr %struct.one_atexit_routine, %struct.one_atexit_routine* %r, i32 0, i32 1 ; <i32*> [#uses=1]
store i32 0, i32* %1, align 4
%2 = call i32 @atexit_common(%struct.one_atexit_routine* %r, i8* bitcast ({ }* @__dso_handle to i8*)) nounwind ; <i32> [#uses=1]
ret i32 %2
}
declare i32 @atexit_common(%struct.one_atexit_routine*, i8*) nounwind