1; RUN: llc -mtriple=arm-apple-darwin %s -o %t 2; RUN: FileCheck %s < %t 3; RUN: FileCheck %s -check-prefix=GOT-EQUIV < %t 4 5; GOT equivalent globals references can be replaced by the GOT entry of the 6; final symbol instead. 7 8%struct.data = type { i32, %struct.anon } 9%struct.anon = type { i32, i32 } 10 11; Check that these got equivalent symbols are never emitted or used 12; GOT-EQUIV-NOT: _localgotequiv 13; GOT-EQUIV-NOT: _extgotequiv 14@localfoo = global i32 42 15@localgotequiv = private unnamed_addr constant i32* @localfoo 16 17@extfoo = external global i32 18@extgotequiv = private unnamed_addr constant i32* @extfoo 19 20; Don't replace GOT equivalent usage within instructions and emit the GOT 21; equivalent since it can't be replaced by the GOT entry. @bargotequiv is 22; used by an instruction inside @t0. 23; 24; CHECK: l_bargotequiv: 25; CHECK-NEXT: .long _extbar 26@extbar = external global i32 27@bargotequiv = private unnamed_addr constant i32* @extbar 28 29@table = global [4 x %struct.data] [ 30; CHECK-LABEL: _table 31 %struct.data { i32 1, %struct.anon { i32 2, i32 3 } }, 32; Test GOT equivalent usage inside nested constant arrays. 33; CHECK: .long 5 34; CHECK-NOT: l_localgotequiv-(_table+20) 35; CHECK-NEXT: L_localfoo$non_lazy_ptr-(_table+20) 36 %struct.data { i32 4, %struct.anon { i32 5, 37 i32 sub (i32 ptrtoint (i32** @localgotequiv to i32), 38 i32 ptrtoint (i32* getelementptr inbounds ([4 x %struct.data], [4 x %struct.data]* @table, i32 0, i32 1, i32 1, i32 1) to i32))} 39 }, 40; CHECK: .long 5 41; CHECK-NOT: l_extgotequiv-(_table+32) 42; CHECK-NEXT: L_extfoo$non_lazy_ptr-(_table+32) 43 %struct.data { i32 4, %struct.anon { i32 5, 44 i32 sub (i32 ptrtoint (i32** @extgotequiv to i32), 45 i32 ptrtoint (i32* getelementptr inbounds ([4 x %struct.data], [4 x %struct.data]* @table, i32 0, i32 2, i32 1, i32 1) to i32))} 46 }, 47; Test support for arbitrary constants into the GOTPCREL offset 48; CHECK: .long 5 49; CHECK-NOT: (l_extgotequiv-(_table+44))+24 50; CHECK-NEXT: L_extfoo$non_lazy_ptr-(_table+20) 51 %struct.data { i32 4, %struct.anon { i32 5, 52 i32 add (i32 sub (i32 ptrtoint (i32** @extgotequiv to i32), 53 i32 ptrtoint (i32* getelementptr inbounds ([4 x %struct.data], [4 x %struct.data]* @table, i32 0, i32 3, i32 1, i32 1) to i32)), 54 i32 24)} 55 } 56], align 16 57 58; Test multiple uses of GOT equivalents. 59; CHECK-LABEL: _delta 60; CHECK: .long L_extfoo$non_lazy_ptr-_delta 61@delta = global i32 sub (i32 ptrtoint (i32** @extgotequiv to i32), 62 i32 ptrtoint (i32* @delta to i32)) 63 64; CHECK-LABEL: _deltaplus: 65; CHECK: .long L_localfoo$non_lazy_ptr-(_deltaplus-55) 66@deltaplus = global i32 add (i32 sub (i32 ptrtoint (i32** @localgotequiv to i32), 67 i32 ptrtoint (i32* @deltaplus to i32)), 68 i32 55) 69 70define i32 @t0(i32 %a) { 71 %x = add i32 sub (i32 ptrtoint (i32** @bargotequiv to i32), 72 i32 ptrtoint (i32 (i32)* @t0 to i32)), %a 73 ret i32 %x 74} 75