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
; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers | FileCheck %s

target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"

declare void @somefunc(i32*)

; CHECK-LABEL: underalign:
; CHECK:      global.get $push[[L1:.+]]=, __stack_pointer{{$}}
; CHECK-NEXT: i32.const $push[[L2:.+]]=, 16
; CHECK-NEXT: i32.sub   $push[[L10:.+]]=, $pop[[L1]], $pop[[L2]]
; CHECK-NEXT: local.tee $push{{.+}}=, [[SP:.+]], $pop[[L10]]

; CHECK:      local.get $push[[L3:.+]]=, [[SP]]{{$}}
; CHECK:      i32.add   $push[[underaligned:.+]]=, $pop[[L3]], $pop{{.+}}
; CHECK-NEXT: call      somefunc, $pop[[underaligned]]

; CHECK:      local.get $push[[M4:.+]]=, [[SP]]{{$}}
; CHECK:      i32.add   $push[[L5:.+]]=, $pop[[M4]], $pop{{.+}}
; CHECK-NEXT: global.set __stack_pointer, $pop[[L5]]
define void @underalign() {
entry:
  %underaligned = alloca i32, align 8
  call void @somefunc(i32* %underaligned)
  ret void
}

; CHECK-LABEL: overalign:
; CHECK:      global.get $push[[L10:.+]]=, __stack_pointer{{$}}
; CHECK-NEXT: local.tee  $push[[L9:.+]]=, [[BP:.+]], $pop[[L10]]
; CHECK-NEXT: i32.const  $push[[L2:.+]]=, 32
; CHECK-NEXT: i32.sub    $push[[L8:.+]]=, $pop[[L9]], $pop[[L2]]
; CHECK-NEXT: i32.const  $push[[L3:.+]]=, -32
; CHECK-NEXT: i32.and    $push[[L7:.+]]=, $pop[[L8]], $pop[[L3]]
; CHECK-NEXT: local.tee  $push{{.+}}=, [[SP:.+]], $pop[[L7]]

; CHECK:      local.get  $push[[M5:.+]]=, [[SP]]{{$}}
; CHECK:      call       somefunc, $pop[[M5]]{{$}}

; CHECK:      local.get  $push[[M6:.+]]=, [[BP]]{{$}}
; CHECK-NEXT: global.set __stack_pointer, $pop[[M6]]
define void @overalign() {
entry:
  %overaligned = alloca i32, align 32
  call void @somefunc(i32* %overaligned)
  ret void
}

; CHECK-LABEL: over_and_normal_align:
; CHECK:      global.get $push[[L14:.+]]=, __stack_pointer{{$}}
; CHECK-NEXT: local.tee  $push[[L13:.+]]=, [[BP:.+]], $pop[[L14]]
; CHECK:      i32.sub    $push[[L12:.+]]=, $pop[[L13]], $pop{{.+}}
; CHECK:      i32.and    $push[[L11:.+]]=, $pop[[L12]], $pop{{.+}}
; CHECK-NEXT: local.tee  $push{{.+}}=, [[SP:.+]], $pop[[L11]]

; CHECK:      local.get  $push[[M6:.+]]=, [[SP]]{{$}}
; CHECK:      i32.add    $push[[L6:.+]]=, $pop[[M6]], $pop{{.+}}
; CHECK-NEXT: call       somefunc, $pop[[L6]]
; CHECK:      local.get  $push[[M7:.+]]=, [[SP]]{{$}}
; CHECK:      i32.add    $push[[L8:.+]]=, $pop[[M7]], $pop{{.+}}
; CHECK-NEXT: call       somefunc, $pop[[L8]]

; CHECK:      local.get  $push[[L6:.+]]=, [[BP]]{{$}}
; CHECK-NEXT: global.set __stack_pointer, $pop[[L6]]
define void @over_and_normal_align() {
entry:
  %over = alloca i32, align 32
  %normal = alloca i32
  call void @somefunc(i32* %over)
  call void @somefunc(i32* %normal)
  ret void
}

; CHECK-LABEL: dynamic_overalign:
; CHECK:      global.get $push[[L18:.+]]=, __stack_pointer{{$}}
; CHECK-NEXT: local.tee  $push[[L17:.+]]=, [[SP:.+]], $pop[[L18]]
; CHECK-NEXT: local.set  [[BP:.+]], $pop[[L17]]
; CHECK:      local.tee  $push{{.+}}=, [[SP_2:.+]], $pop{{.+}}

; CHECK:      local.get  $push[[M8:.+]]=, [[SP_2]]{{$}}
; CHECK:      call       somefunc, $pop[[M8]]

; CHECK:      local.get  $push[[M9:.+]]=, [[BP]]{{$}}
; CHECK-NEXT: global.set __stack_pointer, $pop[[M9]]
define void @dynamic_overalign(i32 %num) {
entry:
  %dynamic = alloca i32, i32 %num, align 32
  call void @somefunc(i32* %dynamic)
  ret void
}

; CHECK-LABEL: overalign_and_dynamic:
; CHECK:      global.get $push[[L21:.+]]=, __stack_pointer{{$}}
; CHECK-NEXT: local.tee  $push[[L20:.+]]=, [[BP:.+]], $pop[[L21]]
; CHECK:      i32.sub    $push[[L19:.+]]=, $pop[[L20]], $pop{{.+}}
; CHECK:      i32.and    $push[[L18:.+]]=, $pop[[L19]], $pop{{.+}}
; CHECK:      local.tee  $push{{.+}}=, [[FP:.+]], $pop[[L18]]
; CHECK:      local.get  $push[[M10:.+]]=, [[FP]]{{$}}
; CHECK:      i32.sub    $push[[L16:.+]]=, $pop[[M10]], $pop{{.+}}
; CHECK-NEXT: local.tee  $push{{.+}}=, [[SP:.+]], $pop[[L16]]

; CHECK:      local.get  $push[[over:.+]]=, [[FP]]
; CHECK-NEXT: call       somefunc, $pop[[over]]
; CHECK:      local.get  $push[[another:.+]]=, [[SP]]
; CHECK-NEXT: call       somefunc, $pop[[another]]

; CHECK:      local.get  $push[[M11:.+]]=, [[BP]]{{$}}
; CHECK-NEXT: global.set __stack_pointer, $pop[[M11]]
define void @overalign_and_dynamic(i32 %num) {
entry:
  %over = alloca i32, align 32
  %dynamic = alloca i32, i32 %num
  call void @somefunc(i32* %over)
  call void @somefunc(i32* %dynamic)
  ret void
}

; CHECK-LABEL: overalign_static_and_dynamic:
; CHECK:      global.get $push[[L26:.+]]=, __stack_pointer{{$}}
; CHECK-NEXT: local.tee  $push[[L25:.+]]=, [[BP:.+]], $pop[[L26]]
; CHECK:      i32.sub    $push[[L24:.+]]=, $pop[[L25]], $pop{{.+}}
; CHECK:      i32.and    $push[[L23:.+]]=, $pop[[L24]], $pop{{.+}}
; CHECK:      local.tee  $push{{.+}}=, [[FP:.+]], $pop[[L23]]
; CHECK:      local.get  $push[[M12:.+]]=, [[FP]]{{$}}
; CHECK:      i32.sub    $push[[L21:.+]]=, $pop[[M12]], $pop{{.+}}
; CHECK-NEXT: local.tee  $push{{.+}}=, [[SP:.+]], $pop[[L21]]

; CHECK:      local.get  $push[[L19:.+]]=, [[FP]]
; CHECK:      local.tee  $push[[L18:.+]]=, [[FP_2:.+]], $pop[[L19]]
; CHECK:      i32.add    $push[[over:.+]]=, $pop[[L18]], $pop{{.+}}
; CHECK-NEXT: call       somefunc, $pop[[over]]
; CHECK:      local.get  $push[[M12:.+]]=, [[SP]]
; CHECK:      call       somefunc, $pop[[M12]]
; CHECK:      local.get  $push[[M13:.+]]=, [[FP_2]]
; CHECK:      i32.add    $push[[static:.+]]=, $pop[[M13]], $pop{{.+}}
; CHECK-NEXT: call       somefunc, $pop[[static]]

; CHECK:      local.get  $push[[M14:.+]]=, [[BP]]{{$}}
; CHECK-NEXT: global.set __stack_pointer, $pop[[M14]]
define void @overalign_static_and_dynamic(i32 %num) {
entry:
  %over = alloca i32, align 32
  %dynamic = alloca i32, i32 %num
  %static = alloca i32
  call void @somefunc(i32* %over)
  call void @somefunc(i32* %dynamic)
  call void @somefunc(i32* %static)
  ret void
}