1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=thumbv7-apple-darwin9 -relocation-model=pic | FileCheck %s --check-prefix=CHECK --check-prefix=PIC 2*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=thumbv7-apple-ios -relocation-model=pic -mcpu=swift -mattr=+no-movt | FileCheck %s --check-prefix=CHECK --check-prefix=PIC-NOMOVT 3*9880d681SAndroid Build Coastguard Worker 4*9880d681SAndroid Build Coastguard Worker %struct.anon = type { void ()* } 5*9880d681SAndroid Build Coastguard Worker %struct.one_atexit_routine = type { %struct.anon, i32, i8* } 6*9880d681SAndroid Build Coastguard Worker@__dso_handle = external global { } ; <{ }*> [#uses=1] 7*9880d681SAndroid Build Coastguard Worker@llvm.used = appending global [1 x i8*] [i8* bitcast (i32 (void ()*)* @atexit to i8*)], section "llvm.metadata" ; <[1 x i8*]*> [#uses=0] 8*9880d681SAndroid Build Coastguard Worker 9*9880d681SAndroid Build Coastguard Workerdefine hidden i32 @atexit(void ()* %func) nounwind { 10*9880d681SAndroid Build Coastguard Workerentry: 11*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: atexit: 12*9880d681SAndroid Build Coastguard Worker; CHECK-PIC: add r0, pc 13*9880d681SAndroid Build Coastguard Worker; CHECK-NOMOVT: ldr r[[REGNUM:[0-9]+]], LCPI0_0 14*9880d681SAndroid Build Coastguard Worker; CHECK-NOMOVT: LPC0_0: 15*9880d681SAndroid Build Coastguard Worker; CHECK-NOMOVT: add r[[REGNUM]], pc 16*9880d681SAndroid Build Coastguard Worker; CHECK-NOMOVT: ldr r1, [r[[REGNUM]] 17*9880d681SAndroid Build Coastguard Worker; CHECK-NOMOVT: blx _atexit_common 18*9880d681SAndroid Build Coastguard Worker; CHECK-NOMOVT: LCPI0_0: 19*9880d681SAndroid Build Coastguard Worker; CHECK-NOMOVT: .long L___dso_handle$non_lazy_ptr-(LPC0_0+4) 20*9880d681SAndroid Build Coastguard Worker %r = alloca %struct.one_atexit_routine, align 4 ; <%struct.one_atexit_routine*> [#uses=3] 21*9880d681SAndroid Build Coastguard Worker %0 = getelementptr %struct.one_atexit_routine, %struct.one_atexit_routine* %r, i32 0, i32 0, i32 0 ; <void ()**> [#uses=1] 22*9880d681SAndroid Build Coastguard Worker store void ()* %func, void ()** %0, align 4 23*9880d681SAndroid Build Coastguard Worker %1 = getelementptr %struct.one_atexit_routine, %struct.one_atexit_routine* %r, i32 0, i32 1 ; <i32*> [#uses=1] 24*9880d681SAndroid Build Coastguard Worker store i32 0, i32* %1, align 4 25*9880d681SAndroid Build Coastguard Worker %2 = call i32 @atexit_common(%struct.one_atexit_routine* %r, i8* bitcast ({ }* @__dso_handle to i8*)) nounwind ; <i32> [#uses=1] 26*9880d681SAndroid Build Coastguard Worker ret i32 %2 27*9880d681SAndroid Build Coastguard Worker} 28*9880d681SAndroid Build Coastguard Worker 29*9880d681SAndroid Build Coastguard Workerdeclare i32 @atexit_common(%struct.one_atexit_routine*, i8*) nounwind 30