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
|
# RUN: llc -mtriple=x86_64-unknown-linux-gnu -run-pass shadow-call-stack -verify-machineinstrs -o - %s | FileCheck %s
--- |
define void @no_return() #0 { ret void }
define void @normal_return() #0 { ret void }
define void @normal_return_leaf_func() #0 { ret void }
define void @short_leaf_func() #0 { ret void }
define void @normal_tail_call() #0 { ret void }
define void @r11_tail_call() #0 { ret void }
define void @conditional_tail_call() #0 { ret void }
define void @r10_live_in() #0 { ret void }
attributes #0 = { shadowcallstack }
...
---
# CHECK-LABEL: name: no_return
name: no_return
tracksRegLiveness: true
frameInfo:
adjustsStack: true # not a leaf function
body: |
; CHECK: bb.0:
bb.0:
; CHECK-NEXT: $eax = MOV32ri 13
$eax = MOV32ri 13
...
---
# CHECK-LABEL: name: normal_return
name: normal_return
tracksRegLiveness: true
frameInfo:
adjustsStack: true # not a leaf function
body: |
; CHECK: bb.0:
bb.0:
; CHECK: $r10 = MOV64rm $rsp, 1, $noreg, 0, $noreg
; CHECK-NEXT: $r11 = XOR64rr undef $r11, undef $r11, implicit-def $eflags
; CHECK-NEXT: ADD64mi8 $r11, 1, $noreg, 0, $gs, 8, implicit-def $eflags
; CHECK-NEXT: $r11 = MOV64rm $r11, 1, $noreg, 0, $gs
; CHECK-NEXT: MOV64mr $r11, 1, $noreg, 0, $gs, $r10
; CHECK-NEXT: $eax = MOV32ri 13
$eax = MOV32ri 13
; CHECK-NEXT: $r11 = XOR64rr undef $r11, undef $r11, implicit-def $eflags
; CHECK-NEXT: $r10 = MOV64rm $r11, 1, $noreg, 0, $gs
; CHECK-NEXT: $r10 = MOV64rm $r10, 1, $noreg, 0, $gs
; CHECK-NEXT: SUB64mi8 $r11, 1, $noreg, 0, $gs, 8, implicit-def $eflags
; CHECK-NEXT: CMP64mr $rsp, 1, $noreg, 0, $noreg, $r10, implicit-def $eflags
; CHECK-NEXT: JNE_1 %bb.1, implicit $eflags
; CHECK-NEXT: RETQ $eax
RETQ $eax
; CHECK: bb.1:
; CHECK-NEXT; TRAP
...
---
# CHECK-LABEL: name: normal_return_leaf_func
name: normal_return_leaf_func
tracksRegLiveness: true
frameInfo:
adjustsStack: false # leaf function
body: |
; CHECK: bb.0:
; CHECK: liveins: $rcx
bb.0:
liveins: $rcx
; CHECK: $rdx = MOV64rm $rsp, 1, $noreg, 0, $noreg
; CHECK-NEXT: $eax = MOV32ri 0
$eax = MOV32ri 0
; CHECK-NEXT: CMP64ri8 $rcx, 5, implicit-def $eflags
CMP64ri8 $rcx, 5, implicit-def $eflags
; CHECK-NEXT: JA_1 %bb.1, implicit $eflags
JA_1 %bb.1, implicit $eflags
; CHECK-NEXT: JMP_1 %bb.2
JMP_1 %bb.2
; CHECK: bb.1
; CHECK: liveins: $eax, $rdx
bb.1:
liveins: $eax
; CHECKT: $eax = MOV32ri 1
$eax = MOV32ri 1
; CHECK: bb.2
; CHECK: liveins: $eax, $rdx
bb.2:
liveins: $eax
; CHECK: CMP64mr $rsp, 1, $noreg, 0, $noreg, $rdx, implicit-def $eflags
; CHECK-NEXT: JNE_1 %bb.3, implicit $eflags
; CHECK-NEXT: RETQ $eax
RETQ $eax
; CHECK: bb.3:
; CHECK-NEXT; TRAP
...
---
# CHECK-LABEL: name: short_leaf_func
name: short_leaf_func
tracksRegLiveness: true
frameInfo:
adjustsStack: false # leaf function
body: |
; CHECK: bb.0:
bb.0:
; Ensure these are not counted as machine instructions
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
CFI_INSTRUCTION 0
DBG_VALUE 0
DBG_VALUE 0
DBG_VALUE 0
; CHECK: $eax = MOV32ri 13
$eax = MOV32ri 13
; CHECK-NEXT: RETQ $eax
RETQ $eax
...
---
# CHECK-LABEL: name: normal_tail_call
name: normal_tail_call
tracksRegLiveness: true
frameInfo:
adjustsStack: true # not a leaf function
body: |
; CHECK: bb.0:
bb.0:
; CHECK: $r10 = MOV64rm $rsp, 1, $noreg, 0, $noreg
; CHECK-NEXT: $r11 = XOR64rr undef $r11, undef $r11, implicit-def $eflags
; CHECK-NEXT: ADD64mi8 $r11, 1, $noreg, 0, $gs, 8, implicit-def $eflags
; CHECK-NEXT: $r11 = MOV64rm $r11, 1, $noreg, 0, $gs
; CHECK-NEXT: MOV64mr $r11, 1, $noreg, 0, $gs, $r10
; CHECK-NEXT: $eax = MOV32ri 13
$eax = MOV32ri 13
; CHECK-NEXT: $r11 = XOR64rr undef $r11, undef $r11, implicit-def $eflags
; CHECK-NEXT: $r10 = MOV64rm $r11, 1, $noreg, 0, $gs
; CHECK-NEXT: $r10 = MOV64rm $r10, 1, $noreg, 0, $gs
; CHECK-NEXT: SUB64mi8 $r11, 1, $noreg, 0, $gs, 8, implicit-def $eflags
; CHECK-NEXT: CMP64mr $rsp, 1, $noreg, 0, $noreg, $r10, implicit-def $eflags
; CHECK-NEXT: JNE_1 %bb.1, implicit $eflags
; CHECK-NEXT: TAILJMPr64 $rax
TAILJMPr64 $rax
; CHECK: bb.1:
; CHECK-NEXT; TRAP
...
---
# CHECK-LABEL: name: r11_tail_call
name: r11_tail_call
tracksRegLiveness: true
frameInfo:
adjustsStack: true # not a leaf function
body: |
; CHECK: bb.0:
bb.0:
; CHECK: $r10 = MOV64rm $rsp, 1, $noreg, 0, $noreg
; CHECK-NEXT: $r11 = XOR64rr undef $r11, undef $r11, implicit-def $eflags
; CHECK-NEXT: ADD64mi8 $r11, 1, $noreg, 0, $gs, 8, implicit-def $eflags
; CHECK-NEXT: $r11 = MOV64rm $r11, 1, $noreg, 0, $gs
; CHECK-NEXT: MOV64mr $r11, 1, $noreg, 0, $gs, $r10
; CHECK-NEXT: $eax = MOV32ri 13
$eax = MOV32ri 13
; CHECK-NEXT: $r10 = XOR64rr undef $r10, undef $r10, implicit-def $eflags
; CHECK-NEXT: $r10 = MOV64rm $r10, 1, $noreg, 0, $gs
; CHECK-NEXT: $r10 = MOV64rm $r10, 1, $noreg, 0, $gs
; CHECK-NEXT: SUB64mi8 $noreg, 1, $noreg, 0, $gs, 8, implicit-def $eflags
; CHECK-NEXT: CMP64mr $rsp, 1, $noreg, 0, $noreg, $r10, implicit-def $eflags
; CHECK-NEXT: JNE_1 %bb.1, implicit $eflags
; CHECK-NEXT: TAILJMPr64 undef $r11
TAILJMPr64 undef $r11
; CHECK: bb.1:
; CHECK-NEXT; TRAP
...
---
# CHECK-LABEL: name: conditional_tail_call
name: conditional_tail_call
tracksRegLiveness: true
frameInfo:
adjustsStack: true # not a leaf function
body: |
; CHECK: bb.0:
bb.0:
; CHECK: $eax = MOV32ri 13
$eax = MOV32ri 13
; CHECK-NEXT: TAILJMPd64_CC @conditional_tail_call, undef $eflags
TAILJMPd64_CC @conditional_tail_call, undef $eflags
...
---
# CHECK-LABEL: name: r10_live_in
name: r10_live_in
tracksRegLiveness: true
frameInfo:
adjustsStack: true # not a leaf function
body: |
; CHECK: bb.0:
; CHECK: liveins: $r10
bb.0:
liveins: $r10
; CHECK: $eax = MOV32ri 13
$eax = MOV32ri 13
; CHECK-NEXT: RETQ $eax
RETQ $eax
...
|