brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.6 KiB · b98665c Raw
123 lines · plain
1; RUN: llc -mtriple=i386-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 76; Test indirect local symbols.77; CHECK-LABEL: _localindirect78; CHECK: .long 6560379@localindirect = internal constant i32  6560380@got.localindirect = private unnamed_addr constant ptr @localindirect81 82; CHECK-LABEL: _localindirectuser:83; CHECK: .long   L_localindirect$non_lazy_ptr-_localindirectuser84@localindirectuser = internal constant85  i32 sub (i32 ptrtoint (ptr @got.localindirect to i32),86           i32 ptrtoint (ptr @localindirectuser to i32))87 88; Test internal indirect local symbols where the user doesn't see the89; definition of the other symbols yet.90 91; We used to check if the symbol is defined and not external to guess if it has92; local linkage, but that doesn't work if the symbol is defined after. The code93; should check if the GlobalValue itself has local linkage.94 95; CHECK-LABEL: _undeflocalindirectuser:96; CHECK: .long L_undeflocalindirect$non_lazy_ptr-_undeflocalindirectuser97@undeflocalindirectuser = internal constant98  i32 sub (i32 ptrtoint (ptr @got.undeflocalindirect to i32),99           i32 ptrtoint (ptr @undeflocalindirectuser to i32)),100  section "__TEXT,__const"101 102; CHECK-LABEL: _undeflocalindirect:103; CHECK: .long 65603104@undeflocalindirect = internal constant i32  65603105@got.undeflocalindirect = private unnamed_addr constant ptr @undeflocalindirect106 107; CHECK-LABEL: .section __IMPORT,__pointers108 109; CHECK-LABEL: L_localfoo$non_lazy_ptr:110; CHECK: .indirect_symbol _localfoo111; CHECK-NOT: .long _localfoo112; CHECK-NEXT: .long 0113 114; CHECK-LABEL: L_localindirect$non_lazy_ptr:115; CHECK: .indirect_symbol _localindirect116; CHECK-NOT: .long 0117; CHECK-NEXT: .long _localindirect118 119; CHECK-LABEL: L_undeflocalindirect$non_lazy_ptr:120; CHECK: .indirect_symbol _undeflocalindirect121; CHECK-NOT: .long 0122; CHECK-NEXT: .long _undeflocalindirect123