brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · 07f59d8 Raw
75 lines · plain
1; RUN: llc -mtriple=arm-apple-darwin %s -o %t2; RUN:  FileCheck %s < %t3; RUN:  FileCheck %s -check-prefix=GOT-EQUIV < %t4 5; GOT equivalent globals references can be replaced by the GOT entry of the6; 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 used12; GOT-EQUIV-NOT: _localgotequiv13; GOT-EQUIV-NOT: _extgotequiv14@localfoo = global i32 4215@localgotequiv = private unnamed_addr constant ptr @localfoo16 17@extfoo = external global i3218@extgotequiv = private unnamed_addr constant ptr @extfoo19 20; Don't replace GOT equivalent usage within instructions and emit the GOT21; equivalent since it can't be replaced by the GOT entry. @bargotequiv is22; used by an instruction inside @t0.23;24; CHECK: l_bargotequiv:25; CHECK-NEXT:  .long   _extbar26@extbar = external global i3227@bargotequiv = private unnamed_addr constant ptr @extbar28 29@table = global [4 x %struct.data] [30; CHECK-LABEL: _table31  %struct.data { i32 1, %struct.anon { i32 2, i32 3 } },32; Test GOT equivalent usage inside nested constant arrays.33; CHECK: .long   534; 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 (ptr @localgotequiv to i32),38             i32 ptrtoint (ptr getelementptr inbounds ([4 x %struct.data], ptr @table, i32 0, i32 1, i32 1, i32 1) to i32))}39  },40; CHECK: .long   541; 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 (ptr @extgotequiv to i32),45             i32 ptrtoint (ptr getelementptr inbounds ([4 x %struct.data], ptr @table, i32 0, i32 2, i32 1, i32 1) to i32))}46  },47; Test support for arbitrary constants into the GOTPCREL offset48; CHECK: .long   549; CHECK-NOT: (l_extgotequiv-(_table+44))+2450; 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 (ptr @extgotequiv to i32),53                      i32 ptrtoint (ptr getelementptr inbounds ([4 x %struct.data], ptr @table, i32 0, i32 3, i32 1, i32 1) to i32)),54                      i32 24)}55  }56], align 1657 58; Test multiple uses of GOT equivalents.59; CHECK-LABEL: _delta60; CHECK: .long   L_extfoo$non_lazy_ptr-_delta61@delta = global i32 sub (i32 ptrtoint (ptr @extgotequiv to i32),62                         i32 ptrtoint (ptr @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 (ptr @localgotequiv to i32),67                             i32 ptrtoint (ptr @deltaplus to i32)),68                             i32 55)69 70define i32 @t0(i32 %a) {71  %x = add i32 sub (i32 ptrtoint (ptr @bargotequiv to i32),72                    i32 ptrtoint (ptr @t0 to i32)), %a73  ret i32 %x74}75