Matthias Braun | 141d1c9 | 2015-07-17 23:18:26 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s -mtriple=thumbv7-apple-darwin9 -relocation-model=pic | FileCheck %s --check-prefix=CHECK --check-prefix=PIC |
| 2 | ; RUN: llc < %s -mtriple=thumbv7-apple-ios -relocation-model=pic -mcpu=swift -mattr=+no-movt | FileCheck %s --check-prefix=CHECK --check-prefix=PIC-NOMOVT |
Evan Cheng | dc99f07 | 2009-07-23 23:09:51 +0000 | [diff] [blame] | 3 | |
| 4 | %struct.anon = type { void ()* } |
| 5 | %struct.one_atexit_routine = type { %struct.anon, i32, i8* } |
| 6 | @__dso_handle = external global { } ; <{ }*> [#uses=1] |
| 7 | @llvm.used = appending global [1 x i8*] [i8* bitcast (i32 (void ()*)* @atexit to i8*)], section "llvm.metadata" ; <[1 x i8*]*> [#uses=0] |
| 8 | |
Rafael Espindola | 29dda21 | 2010-06-17 15:18:27 +0000 | [diff] [blame] | 9 | define hidden i32 @atexit(void ()* %func) nounwind { |
Evan Cheng | dc99f07 | 2009-07-23 23:09:51 +0000 | [diff] [blame] | 10 | entry: |
Stephen Lin | d24ab20 | 2013-07-14 06:24:09 +0000 | [diff] [blame] | 11 | ; CHECK-LABEL: atexit: |
Matthias Braun | 141d1c9 | 2015-07-17 23:18:26 +0000 | [diff] [blame] | 12 | ; CHECK-PIC: add r0, pc |
| 13 | ; CHECK-NOMOVT: ldr r[[REGNUM:[0-9]+]], LCPI0_0 |
| 14 | ; CHECK-NOMOVT: LPC0_0: |
| 15 | ; CHECK-NOMOVT: add r[[REGNUM]], pc |
| 16 | ; CHECK-NOMOVT: ldr r1, [r[[REGNUM]] |
| 17 | ; CHECK-NOMOVT: blx _atexit_common |
| 18 | ; CHECK-NOMOVT: LCPI0_0: |
| 19 | ; CHECK-NOMOVT: .long L___dso_handle$non_lazy_ptr-(LPC0_0+4) |
Evan Cheng | dc99f07 | 2009-07-23 23:09:51 +0000 | [diff] [blame] | 20 | %r = alloca %struct.one_atexit_routine, align 4 ; <%struct.one_atexit_routine*> [#uses=3] |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 21 | %0 = getelementptr %struct.one_atexit_routine, %struct.one_atexit_routine* %r, i32 0, i32 0, i32 0 ; <void ()**> [#uses=1] |
Evan Cheng | dc99f07 | 2009-07-23 23:09:51 +0000 | [diff] [blame] | 22 | store void ()* %func, void ()** %0, align 4 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 23 | %1 = getelementptr %struct.one_atexit_routine, %struct.one_atexit_routine* %r, i32 0, i32 1 ; <i32*> [#uses=1] |
Evan Cheng | dc99f07 | 2009-07-23 23:09:51 +0000 | [diff] [blame] | 24 | store i32 0, i32* %1, align 4 |
Rafael Espindola | 29dda21 | 2010-06-17 15:18:27 +0000 | [diff] [blame] | 25 | %2 = call i32 @atexit_common(%struct.one_atexit_routine* %r, i8* bitcast ({ }* @__dso_handle to i8*)) nounwind ; <i32> [#uses=1] |
Evan Cheng | dc99f07 | 2009-07-23 23:09:51 +0000 | [diff] [blame] | 26 | ret i32 %2 |
| 27 | } |
| 28 | |
Rafael Espindola | 29dda21 | 2010-06-17 15:18:27 +0000 | [diff] [blame] | 29 | declare i32 @atexit_common(%struct.one_atexit_routine*, i8*) nounwind |