reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
  141
  142
  143
  144
  145
  146
  147
  148
  149
  150
  151
; RUN: llc < %s -emulated-tls -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic -pie-copy-relocations \
; RUN:   | FileCheck -check-prefix=X64 %s
; RUN: llc < %s -emulated-tls -mcpu=generic -mtriple=i386-linux-gnu -relocation-model=pic -pie-copy-relocations \
; RUN:   | FileCheck -check-prefix=X32 %s

; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic -pie-copy-relocations \
; RUN:   | FileCheck -check-prefix=X64 %s
; RUN: llc < %s -mcpu=generic -mtriple=i386-linux-gnu -relocation-model=pic -pie-copy-relocations \
; RUN:   | FileCheck -check-prefix=X32 %s

; External Linkage
@a = global i32 0, align 4

define i32 @my_access_global_a() #0 {
; X32-LABEL: my_access_global_a:
; X32:       addl $_GLOBAL_OFFSET_TABLE_{{.*}}, %eax
; X32-NEXT:  movl a@GOTOFF(%eax), %eax
; X64-LABEL: my_access_global_a:
; X64:       movl a(%rip), %eax

entry:
  %0 = load i32, i32* @a, align 4
  ret i32 %0
}

; WeakAny Linkage
@b = weak global i32 0, align 4

define i32 @my_access_global_b() #0 {
; X32-LABEL: my_access_global_b:
; X32:       addl $_GLOBAL_OFFSET_TABLE_{{.*}}, %eax
; X32-NEXT:  movl b@GOTOFF(%eax), %eax
; X64-LABEL: my_access_global_b:
; X64:       movl b(%rip), %eax

entry:
  %0 = load i32, i32* @b, align 4
  ret i32 %0
}

; Internal Linkage
@c = internal global i32 0, align 4

define i32 @my_access_global_c() #0 {
; X32-LABEL: my_access_global_c:
; X32:       addl $_GLOBAL_OFFSET_TABLE_{{.*}}, %eax
; X32-NEXT:  movl c@GOTOFF(%eax), %eax
; X64-LABEL: my_access_global_c:
; X64:       movl c(%rip), %eax

entry:
  %0 = load i32, i32* @c, align 4
  ret i32 %0
}

; External Linkage, only declaration.
@d = external global i32, align 4

define i32 @my_access_global_load_d() #0 {
; X32-LABEL: my_access_global_load_d:
; X32:       addl $_GLOBAL_OFFSET_TABLE_{{.*}}, %eax
; X32-NEXT:  movl d@GOTOFF(%eax), %eax
; X64-LABEL: my_access_global_load_d:
; X64:       movl d(%rip), %eax

entry:
  %0 = load i32, i32* @d, align 4
  ret i32 %0
}

; ExternalWeak Linkage
@e = extern_weak global i32, align 4

define i32* @my_access_global_d() #0 {
; X32-LABEL: my_access_global_d:
; X32:       addl $_GLOBAL_OFFSET_TABLE_{{.*}}, %eax
; X32:       movl e@GOT(%eax), %eax
; X64-LABEL: my_access_global_d:
; X64:       movq e@GOTPCREL(%rip), %rax

entry:
  ret i32* @e
}

; ExternalWeak hidden Linkage
@he = extern_weak hidden global i32, align 4

define i32* @my_access_global_he() #0 {
; X32-LABEL: my_access_global_he:
; X32:       addl $_GLOBAL_OFFSET_TABLE_{{.*}}, %eax
; X32:       movl he@GOT(%eax), %eax
; X64-LABEL: my_access_global_he:
; X64:       movq he@GOTPCREL(%rip), %rax
  ret i32* @he
}


; External Linkage, only declaration, store a value.

define i32 @my_access_global_store_d() #0 {
; X32-LABEL: my_access_global_store_d:
; X32:       addl $_GLOBAL_OFFSET_TABLE_{{.*}}, %eax
; X32-NEXT:  movl $2, d@GOTOFF(%eax)
; X64-LABEL: my_access_global_store_d:
; X64:  movl $2, d(%rip)

entry:
  store i32 2, i32* @d, align 4
  ret i32 0
}

; External Linkage, function pointer access.
declare i32 @access_fp(i32 ()*)
declare i32 @foo()

define i32 @my_access_fp_foo() #0 {
; X32-LABEL: my_access_fp_foo:
; X32:       addl $_GLOBAL_OFFSET_TABLE_{{.*}}, %ebx
; X32-NEXT:  movl	foo@GOT(%ebx), %eax
; X64-LABEL: my_access_fp_foo:
; X64:       movq foo@GOTPCREL(%rip), %rdi

entry:
  %call = call i32 @access_fp(i32 ()* @foo)
  ret i32 %call
}

; LinkOnceODR Linkage, function pointer access.

$bar = comdat any

define linkonce_odr i32 @bar() comdat {
entry:
  ret i32 0
}

define i32 @my_access_fp_bar() #0 {
; X32-LABEL: my_access_fp_bar:
; X32:       addl $_GLOBAL_OFFSET_TABLE_{{.*}}, %ebx
; X32-NEXT:  leal	bar@GOTOFF(%ebx), %eax
; X64-LABEL: my_access_fp_bar:
; X64:       leaq bar(%rip), %rdi

entry:
  %call = call i32 @access_fp(i32 ()* @bar)
  ret i32 %call
}

!llvm.module.flags = !{!0, !1}
!0 = !{i32 1, !"PIC Level", i32 1}
!1 = !{i32 1, !"PIE Level", i32 1}