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
  205
  206
  207
  208
  209
  210
  211
  212
  213
  214
  215
  216
  217
  218
  219
  220
  221
  222
  223
  224
  225
  226
  227
  228
  229
  230
  231
  232
  233
  234
  235
  236
  237
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -stackrealign -mtriple i386-apple-darwin -mcpu=i486 | FileCheck %s

%struct.foo = type { [88 x i8] }

declare void @bar(i8* nocapture, %struct.foo* align 4 byval) nounwind
declare void @baz(i8*) nounwind

; PR15249
; We can't use rep;movsl here because it clobbers the base pointer in %esi.
define void @test1(%struct.foo* nocapture %x, i32 %y) nounwind {
; CHECK-LABEL: test1:
; CHECK:       ## %bb.0:
; CHECK-NEXT:    pushl %ebp
; CHECK-NEXT:    movl %esp, %ebp
; CHECK-NEXT:    pushl %ebx
; CHECK-NEXT:    pushl %edi
; CHECK-NEXT:    pushl %esi
; CHECK-NEXT:    andl $-16, %esp
; CHECK-NEXT:    subl $80, %esp
; CHECK-NEXT:    movl %esp, %esi
; CHECK-NEXT:    movl 8(%ebp), %ecx
; CHECK-NEXT:    movl 12(%ebp), %edx
; CHECK-NEXT:    movl %esp, %eax
; CHECK-NEXT:    addl $15, %edx
; CHECK-NEXT:    andl $-16, %edx
; CHECK-NEXT:    subl %edx, %eax
; CHECK-NEXT:    movl %eax, %esp
; CHECK-NEXT:    subl $4, %esp
; CHECK-NEXT:    movl 84(%ecx), %edx
; CHECK-NEXT:    movl %edx, 68(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 80(%ecx), %edi
; CHECK-NEXT:    movl 76(%ecx), %ebx
; CHECK-NEXT:    movl 72(%ecx), %edx
; CHECK-NEXT:    movl %edx, 64(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 68(%ecx), %edx
; CHECK-NEXT:    movl %edx, 60(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 64(%ecx), %edx
; CHECK-NEXT:    movl %edx, 56(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 60(%ecx), %edx
; CHECK-NEXT:    movl %edx, 52(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 56(%ecx), %edx
; CHECK-NEXT:    movl %edx, 48(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 52(%ecx), %edx
; CHECK-NEXT:    movl %edx, 44(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 48(%ecx), %edx
; CHECK-NEXT:    movl %edx, 40(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 44(%ecx), %edx
; CHECK-NEXT:    movl %edx, 36(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 40(%ecx), %edx
; CHECK-NEXT:    movl %edx, 32(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 36(%ecx), %edx
; CHECK-NEXT:    movl %edx, 28(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 32(%ecx), %edx
; CHECK-NEXT:    movl %edx, 24(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 28(%ecx), %edx
; CHECK-NEXT:    movl %edx, 20(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 24(%ecx), %edx
; CHECK-NEXT:    movl %edx, 16(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 20(%ecx), %edx
; CHECK-NEXT:    movl %edx, 12(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 16(%ecx), %edx
; CHECK-NEXT:    movl %edx, 8(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 12(%ecx), %edx
; CHECK-NEXT:    movl %edx, 4(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 8(%ecx), %edx
; CHECK-NEXT:    movl %edx, (%esi) ## 4-byte Spill
; CHECK-NEXT:    movl (%ecx), %edx
; CHECK-NEXT:    movl %edx, 72(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 4(%ecx), %ecx
; CHECK-NEXT:    pushl 68(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl %edi
; CHECK-NEXT:    pushl %ebx
; CHECK-NEXT:    pushl 64(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 60(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 56(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 52(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 48(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 44(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 40(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 36(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 32(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 28(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 24(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 20(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 16(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 12(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 8(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 4(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl (%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl %ecx
; CHECK-NEXT:    pushl 72(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl %eax
; CHECK-NEXT:    calll _bar
; CHECK-NEXT:    leal -12(%ebp), %esp
; CHECK-NEXT:    popl %esi
; CHECK-NEXT:    popl %edi
; CHECK-NEXT:    popl %ebx
; CHECK-NEXT:    popl %ebp
; CHECK-NEXT:    retl
  %dynalloc = alloca i8, i32 %y, align 1
  call void @bar(i8* %dynalloc, %struct.foo* align 4 byval %x)
  ret void
}

; PR19012
; Also don't clobber %esi if the dynamic alloca comes after the memcpy.
define void @test2(%struct.foo* nocapture %x, i32 %y, i8* %z) nounwind {
; CHECK-LABEL: test2:
; CHECK:       ## %bb.0:
; CHECK-NEXT:    pushl %ebp
; CHECK-NEXT:    movl %esp, %ebp
; CHECK-NEXT:    pushl %ebx
; CHECK-NEXT:    pushl %edi
; CHECK-NEXT:    pushl %esi
; CHECK-NEXT:    andl $-16, %esp
; CHECK-NEXT:    subl $80, %esp
; CHECK-NEXT:    movl %esp, %esi
; CHECK-NEXT:    movl 12(%ebp), %edi
; CHECK-NEXT:    movl 8(%ebp), %eax
; CHECK-NEXT:    subl $4, %esp
; CHECK-NEXT:    movl 84(%eax), %ecx
; CHECK-NEXT:    movl %ecx, 68(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 80(%eax), %edx
; CHECK-NEXT:    movl 76(%eax), %ebx
; CHECK-NEXT:    movl 72(%eax), %ecx
; CHECK-NEXT:    movl %ecx, 64(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 68(%eax), %ecx
; CHECK-NEXT:    movl %ecx, 60(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 64(%eax), %ecx
; CHECK-NEXT:    movl %ecx, 56(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 60(%eax), %ecx
; CHECK-NEXT:    movl %ecx, 52(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 56(%eax), %ecx
; CHECK-NEXT:    movl %ecx, 48(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 52(%eax), %ecx
; CHECK-NEXT:    movl %ecx, 44(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 48(%eax), %ecx
; CHECK-NEXT:    movl %ecx, 40(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 44(%eax), %ecx
; CHECK-NEXT:    movl %ecx, 36(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 40(%eax), %ecx
; CHECK-NEXT:    movl %ecx, 32(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 36(%eax), %ecx
; CHECK-NEXT:    movl %ecx, 28(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 32(%eax), %ecx
; CHECK-NEXT:    movl %ecx, 24(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 28(%eax), %ecx
; CHECK-NEXT:    movl %ecx, 20(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 24(%eax), %ecx
; CHECK-NEXT:    movl %ecx, 16(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 20(%eax), %ecx
; CHECK-NEXT:    movl %ecx, 12(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 16(%eax), %ecx
; CHECK-NEXT:    movl %ecx, 8(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 12(%eax), %ecx
; CHECK-NEXT:    movl %ecx, 4(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 8(%eax), %ecx
; CHECK-NEXT:    movl %ecx, (%esi) ## 4-byte Spill
; CHECK-NEXT:    movl (%eax), %ecx
; CHECK-NEXT:    movl %ecx, 72(%esi) ## 4-byte Spill
; CHECK-NEXT:    movl 4(%eax), %eax
; CHECK-NEXT:    pushl 68(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl %edx
; CHECK-NEXT:    pushl %ebx
; CHECK-NEXT:    pushl 64(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 60(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 56(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 52(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 48(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 44(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 40(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 36(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 32(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 28(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 24(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 20(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 16(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 12(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 8(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 4(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl (%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl %eax
; CHECK-NEXT:    pushl 72(%esi) ## 4-byte Folded Reload
; CHECK-NEXT:    pushl 16(%ebp)
; CHECK-NEXT:    calll _bar
; CHECK-NEXT:    addl $96, %esp
; CHECK-NEXT:    movl %esp, %eax
; CHECK-NEXT:    addl $15, %edi
; CHECK-NEXT:    andl $-16, %edi
; CHECK-NEXT:    subl %edi, %eax
; CHECK-NEXT:    movl %eax, %esp
; CHECK-NEXT:    subl $12, %esp
; CHECK-NEXT:    pushl %eax
; CHECK-NEXT:    calll _baz
; CHECK-NEXT:    leal -12(%ebp), %esp
; CHECK-NEXT:    popl %esi
; CHECK-NEXT:    popl %edi
; CHECK-NEXT:    popl %ebx
; CHECK-NEXT:    popl %ebp
; CHECK-NEXT:    retl
  call void @bar(i8* %z, %struct.foo* align 4 byval %x)
  %dynalloc = alloca i8, i32 %y, align 1
  call void @baz(i8* %dynalloc)
  ret void
}

; Check that we do use rep movs if we make the alloca static.
define void @test3(%struct.foo* nocapture %x, i32 %y, i8* %z) nounwind {
; CHECK-LABEL: test3:
; CHECK:       ## %bb.0:
; CHECK-NEXT:    pushl %ebp
; CHECK-NEXT:    movl %esp, %ebp
; CHECK-NEXT:    pushl %edi
; CHECK-NEXT:    pushl %esi
; CHECK-NEXT:    andl $-16, %esp
; CHECK-NEXT:    subl $112, %esp
; CHECK-NEXT:    movl 16(%ebp), %eax
; CHECK-NEXT:    movl 8(%ebp), %esi
; CHECK-NEXT:    leal {{[0-9]+}}(%esp), %edi
; CHECK-NEXT:    movl $22, %ecx
; CHECK-NEXT:    rep;movsl (%esi), %es:(%edi)
; CHECK-NEXT:    movl %eax, (%esp)
; CHECK-NEXT:    calll _bar
; CHECK-NEXT:    leal {{[0-9]+}}(%esp), %eax
; CHECK-NEXT:    movl %eax, (%esp)
; CHECK-NEXT:    calll _baz
; CHECK-NEXT:    leal -8(%ebp), %esp
; CHECK-NEXT:    popl %esi
; CHECK-NEXT:    popl %edi
; CHECK-NEXT:    popl %ebp
; CHECK-NEXT:    retl
  call void @bar(i8* %z, %struct.foo* align 4 byval %x)
  %statalloc = alloca i8, i32 8, align 1
  call void @baz(i8* %statalloc)
  ret void
}