Skip to content

Commit db88f30

Browse files
committed
[RISCV] Add test for saving s10 with cm.push. NFC
If cm.push saves s10, it must also save s11 due to an encoding limitation. We handle this in the code, but had no test for it.
1 parent ac05771 commit db88f30

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

llvm/test/CodeGen/RISCV/push-pop-popret.ll

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3218,3 +3218,74 @@ entry:
32183218
call void @bar(ptr %0, ptr %var)
32193219
ret i32 %x
32203220
}
3221+
3222+
define void @spill_x10() {
3223+
; RV32IZCMP-LABEL: spill_x10:
3224+
; RV32IZCMP: # %bb.0: # %entry
3225+
; RV32IZCMP-NEXT: cm.push {ra, s0-s11}, -64
3226+
; RV32IZCMP-NEXT: .cfi_def_cfa_offset 64
3227+
; RV32IZCMP-NEXT: .cfi_offset s10, -8
3228+
; RV32IZCMP-NEXT: #APP
3229+
; RV32IZCMP-NEXT: li s10, 0
3230+
; RV32IZCMP-NEXT: #NO_APP
3231+
; RV32IZCMP-NEXT: cm.popret {ra, s0-s11}, 64
3232+
;
3233+
; RV64IZCMP-LABEL: spill_x10:
3234+
; RV64IZCMP: # %bb.0: # %entry
3235+
; RV64IZCMP-NEXT: cm.push {ra, s0-s11}, -112
3236+
; RV64IZCMP-NEXT: .cfi_def_cfa_offset 112
3237+
; RV64IZCMP-NEXT: .cfi_offset s10, -16
3238+
; RV64IZCMP-NEXT: #APP
3239+
; RV64IZCMP-NEXT: li s10, 0
3240+
; RV64IZCMP-NEXT: #NO_APP
3241+
; RV64IZCMP-NEXT: cm.popret {ra, s0-s11}, 112
3242+
;
3243+
; RV32IZCMP-SR-LABEL: spill_x10:
3244+
; RV32IZCMP-SR: # %bb.0: # %entry
3245+
; RV32IZCMP-SR-NEXT: cm.push {ra, s0-s11}, -64
3246+
; RV32IZCMP-SR-NEXT: .cfi_def_cfa_offset 64
3247+
; RV32IZCMP-SR-NEXT: .cfi_offset s10, -8
3248+
; RV32IZCMP-SR-NEXT: #APP
3249+
; RV32IZCMP-SR-NEXT: li s10, 0
3250+
; RV32IZCMP-SR-NEXT: #NO_APP
3251+
; RV32IZCMP-SR-NEXT: cm.popret {ra, s0-s11}, 64
3252+
;
3253+
; RV64IZCMP-SR-LABEL: spill_x10:
3254+
; RV64IZCMP-SR: # %bb.0: # %entry
3255+
; RV64IZCMP-SR-NEXT: cm.push {ra, s0-s11}, -112
3256+
; RV64IZCMP-SR-NEXT: .cfi_def_cfa_offset 112
3257+
; RV64IZCMP-SR-NEXT: .cfi_offset s10, -16
3258+
; RV64IZCMP-SR-NEXT: #APP
3259+
; RV64IZCMP-SR-NEXT: li s10, 0
3260+
; RV64IZCMP-SR-NEXT: #NO_APP
3261+
; RV64IZCMP-SR-NEXT: cm.popret {ra, s0-s11}, 112
3262+
;
3263+
; RV32I-LABEL: spill_x10:
3264+
; RV32I: # %bb.0: # %entry
3265+
; RV32I-NEXT: addi sp, sp, -16
3266+
; RV32I-NEXT: .cfi_def_cfa_offset 16
3267+
; RV32I-NEXT: sw s10, 12(sp) # 4-byte Folded Spill
3268+
; RV32I-NEXT: .cfi_offset s10, -4
3269+
; RV32I-NEXT: #APP
3270+
; RV32I-NEXT: li s10, 0
3271+
; RV32I-NEXT: #NO_APP
3272+
; RV32I-NEXT: lw s10, 12(sp) # 4-byte Folded Reload
3273+
; RV32I-NEXT: addi sp, sp, 16
3274+
; RV32I-NEXT: ret
3275+
;
3276+
; RV64I-LABEL: spill_x10:
3277+
; RV64I: # %bb.0: # %entry
3278+
; RV64I-NEXT: addi sp, sp, -16
3279+
; RV64I-NEXT: .cfi_def_cfa_offset 16
3280+
; RV64I-NEXT: sd s10, 8(sp) # 8-byte Folded Spill
3281+
; RV64I-NEXT: .cfi_offset s10, -8
3282+
; RV64I-NEXT: #APP
3283+
; RV64I-NEXT: li s10, 0
3284+
; RV64I-NEXT: #NO_APP
3285+
; RV64I-NEXT: ld s10, 8(sp) # 8-byte Folded Reload
3286+
; RV64I-NEXT: addi sp, sp, 16
3287+
; RV64I-NEXT: ret
3288+
entry:
3289+
tail call void asm sideeffect "li s10, 0", "~{s10}"()
3290+
ret void
3291+
}

0 commit comments

Comments
 (0)