blob: 1f2a7d891671d0defb37e4572246159391f09121 [file] [log] [blame]
; 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 { ptr }
%struct.one_atexit_routine = type { %struct.anon, i32, ptr }
@__dso_handle = external global { } ; <ptr> [#uses=1]
@llvm.used = appending global [1 x ptr] [ptr @atexit], section "llvm.metadata" ; <ptr> [#uses=0]
define i32 @atexit(ptr %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 ; <ptr> [#uses=3]
%0 = getelementptr %struct.one_atexit_routine, ptr %r, i32 0, i32 0, i32 0 ; <ptr> [#uses=1]
store ptr %func, ptr %0, align 4
%1 = getelementptr %struct.one_atexit_routine, ptr %r, i32 0, i32 1 ; <ptr> [#uses=1]
store i32 0, ptr %1, align 4
%2 = call i32 @atexit_common(ptr %r, ptr @__dso_handle) nounwind ; <i32> [#uses=1]
ret i32 %2
}
declare i32 @atexit_common(ptr, ptr) nounwind