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
  152
  153
  154
  155
  156
  157
  158
  159
  160
  161
  162
  163
  164
  165
  166
  167
  168
  169
  170
  171
  172
  173
  174
  175
  176
  177
  178
  179
  180
  181
  182
  183
  184
  185
  186
  187
  188
  189
  190
  191
  192
  193
  194
  195
  196
  197
  198
  199
  200
  201
  202
  203
  204
; RUN: opt -inline < %s -S -o - -inline-threshold=3  | FileCheck %s

target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

declare void @pad() readnone

define void @outer1(i32* %a) {
; CHECK-LABEL: @outer1(
; CHECK-NOT: call void @inner1
  %b = alloca i32
  call void @inner1(i32* %a, i32* %b)
  ret void
}

define void @inner1(i32* %a, i32* %b) {
  %1 = load i32, i32* %a
  store i32 %1, i32 * %b ; This store does not clobber the first load.
  %2 = load i32, i32* %a
  call void @pad()
  %3 = load i32, i32* %a
  ret void
}


define void @outer2(i32* %a, i32* %b) {
; CHECK-LABEL: @outer2(
; CHECK: call void @inner2
  call void @inner2(i32* %a, i32* %b)
  ret void
}

define void @inner2(i32* %a, i32* %b) {
  %1 = load i32, i32* %a
  store i32 %1, i32 * %b ; This store clobbers the first load.
  %2 = load i32, i32* %a
  call void @pad()
  ret void
}


define void @outer3(i32* %a) {
; CHECK-LABEL: @outer3(
; CHECK: call void @inner3
  call void @inner3(i32* %a)
  ret void
}

declare void @ext()

define void @inner3(i32* %a) {
  %1 = load i32, i32* %a
  call void @ext() ; This call clobbers the first load.
  %2 = load i32, i32* %a
  ret void
}


define void @outer4(i32* %a, i32* %b, i32* %c) {
; CHECK-LABEL: @outer4(
; CHECK-NOT: call void @inner4
  call void @inner4(i32* %a, i32* %b, i1 false)
  ret void
}

define void @inner4(i32* %a, i32* %b, i1 %pred) {
  %1 = load i32, i32* %a
  br i1 %pred, label %cond_true, label %cond_false

cond_true:
  store i32 %1, i32 * %b ; This store does not clobber the first load.
  br label %cond_false

cond_false:
  %2 = load i32, i32* %a
  call void @pad()
  %3 = load i32, i32* %a
  %4 = load i32, i32* %a
  ret void
}


define void @outer5(i32* %a, double %b) {
; CHECK-LABEL: @outer5(
; CHECK-NOT: call void @inner5
  call void @inner5(i32* %a, double %b)
  ret void
}

declare double @llvm.fabs.f64(double) nounwind readnone

define void @inner5(i32* %a, double %b) {
  %1 = load i32, i32* %a
  %2 = call double @llvm.fabs.f64(double %b) ; This intrinsic does not clobber the first load.
  %3 = load i32, i32* %a
  call void @pad()
  ret void
}

define void @outer6(i32* %a, i8* %ptr) {
; CHECK-LABEL: @outer6(
; CHECK-NOT: call void @inner6
  call void @inner6(i32* %a, i8* %ptr)
  ret void
}

declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) argmemonly nounwind

define void @inner6(i32* %a, i8* %ptr) {
  %1 = load i32, i32* %a
  call void @llvm.lifetime.start.p0i8(i64 32, i8* %ptr) ; This intrinsic does not clobber the first load.
  %2 = load i32, i32* %a
  call void @pad()
  %3 = load i32, i32* %a
  ret void
}

define void @outer7(i32* %a) {
; CHECK-LABEL: @outer7(
; CHECK-NOT: call void @inner7
  call void @inner7(i32* %a)
  ret void
}

declare void @ext2() readnone

define void @inner7(i32* %a) {
  %1 = load i32, i32* %a
  call void @ext2() ; This call does not clobber the first load.
  %2 = load i32, i32* %a
  ret void
}


define void @outer8(i32* %a) {
; CHECK-LABEL: @outer8(
; CHECK-NOT: call void @inner8
  call void @inner8(i32* %a, void ()* @ext2)
  ret void
}

define void @inner8(i32* %a, void ()* %f) {
  %1 = load i32, i32* %a
  call void %f() ; This indirect call does not clobber the first load.
  %2 = load i32, i32* %a
  call void @pad()
  call void @pad()
  call void @pad()
  call void @pad()
  call void @pad()
  call void @pad()
  call void @pad()
  call void @pad()
  call void @pad()
  call void @pad()
  call void @pad()
  call void @pad()
  ret void
}


define void @outer9(i32* %a) {
; CHECK-LABEL: @outer9(
; CHECK: call void @inner9
  call void @inner9(i32* %a, void ()* @ext)
  ret void
}

define void @inner9(i32* %a, void ()* %f) {
  %1 = load i32, i32* %a
  call void %f() ; This indirect call clobbers the first load.
  %2 = load i32, i32* %a
  call void @pad()
  call void @pad()
  call void @pad()
  call void @pad()
  call void @pad()
  call void @pad()
  call void @pad()
  call void @pad()
  call void @pad()
  call void @pad()
  call void @pad()
  call void @pad()
  ret void
}


define void @outer10(i32* %a) {
; CHECK-LABEL: @outer10(
; CHECK: call void @inner10
  %b = alloca i32
  call void @inner10(i32* %a, i32* %b)
  ret void
}

define void @inner10(i32* %a, i32* %b) {
  %1 = load i32, i32* %a
  store i32 %1, i32 * %b
  %2 = load volatile i32, i32* %a ; volatile load should be kept.
  call void @pad()
  %3 = load volatile i32, i32* %a ; Same as the above.
  ret void
}