Skip to content

Commit 29828b2

Browse files
authored
[RISCV] Fix double counting scalar CSRs with Zcmp when emitting cfi_offset for RVV CSRs. (#117408)
getCalleeSavedStackSize() already contains RVPushStackSize. Don't subtract it again.
1 parent 0a140c4 commit 29828b2

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

llvm/lib/Target/RISCV/RISCVFrameLowering.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,8 +1758,7 @@ void RISCVFrameLowering::emitCalleeSavedRVVPrologCFI(
17581758
if (!HasFP) {
17591759
uint64_t ScalarLocalVarSize =
17601760
MFI.getStackSize() - RVFI->getCalleeSavedStackSize() -
1761-
RVFI->getRVPushStackSize() - RVFI->getVarArgsSaveSize() +
1762-
RVFI->getRVVPadding();
1761+
RVFI->getVarArgsSaveSize() + RVFI->getRVVPadding();
17631762
FixedSize -= ScalarLocalVarSize;
17641763
}
17651764

llvm/test/CodeGen/RISCV/rvv/rvv-cfi-info.ll

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,13 @@ define riscv_vector_cc <vscale x 1 x i32> @test_vector_callee_cfi(<vscale x 1 x
172172
; OMIT-FP-ZCMP-NEXT: vs2r.v v2, (a0) # Unknown-size Folded Spill
173173
; OMIT-FP-ZCMP-NEXT: addi a0, sp, 16
174174
; OMIT-FP-ZCMP-NEXT: vs4r.v v4, (a0) # Unknown-size Folded Spill
175-
; OMIT-FP-ZCMP-NEXT: .cfi_escape 0x10, 0x61, 0x0b, 0x11, 0x40, 0x22, 0x11, 0x7f, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # $v1 @ cfa - 64 - 1 * vlenb
176-
; OMIT-FP-ZCMP-NEXT: .cfi_escape 0x10, 0x62, 0x0b, 0x11, 0x40, 0x22, 0x11, 0x7d, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # $v2 @ cfa - 64 - 3 * vlenb
177-
; OMIT-FP-ZCMP-NEXT: .cfi_escape 0x10, 0x63, 0x0b, 0x11, 0x40, 0x22, 0x11, 0x7e, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # $v3 @ cfa - 64 - 2 * vlenb
178-
; OMIT-FP-ZCMP-NEXT: .cfi_escape 0x10, 0x64, 0x0b, 0x11, 0x40, 0x22, 0x11, 0x79, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # $v4 @ cfa - 64 - 7 * vlenb
179-
; OMIT-FP-ZCMP-NEXT: .cfi_escape 0x10, 0x65, 0x0b, 0x11, 0x40, 0x22, 0x11, 0x7a, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # $v5 @ cfa - 64 - 6 * vlenb
180-
; OMIT-FP-ZCMP-NEXT: .cfi_escape 0x10, 0x66, 0x0b, 0x11, 0x40, 0x22, 0x11, 0x7b, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # $v6 @ cfa - 64 - 5 * vlenb
181-
; OMIT-FP-ZCMP-NEXT: .cfi_escape 0x10, 0x67, 0x0b, 0x11, 0x40, 0x22, 0x11, 0x7c, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # $v7 @ cfa - 64 - 4 * vlenb
175+
; OMIT-FP-ZCMP-NEXT: .cfi_escape 0x10, 0x61, 0x0b, 0x11, 0x60, 0x22, 0x11, 0x7f, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # $v1 @ cfa - 32 - 1 * vlenb
176+
; OMIT-FP-ZCMP-NEXT: .cfi_escape 0x10, 0x62, 0x0b, 0x11, 0x60, 0x22, 0x11, 0x7d, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # $v2 @ cfa - 32 - 3 * vlenb
177+
; OMIT-FP-ZCMP-NEXT: .cfi_escape 0x10, 0x63, 0x0b, 0x11, 0x60, 0x22, 0x11, 0x7e, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # $v3 @ cfa - 32 - 2 * vlenb
178+
; OMIT-FP-ZCMP-NEXT: .cfi_escape 0x10, 0x64, 0x0b, 0x11, 0x60, 0x22, 0x11, 0x79, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # $v4 @ cfa - 32 - 7 * vlenb
179+
; OMIT-FP-ZCMP-NEXT: .cfi_escape 0x10, 0x65, 0x0b, 0x11, 0x60, 0x22, 0x11, 0x7a, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # $v5 @ cfa - 32 - 6 * vlenb
180+
; OMIT-FP-ZCMP-NEXT: .cfi_escape 0x10, 0x66, 0x0b, 0x11, 0x60, 0x22, 0x11, 0x7b, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # $v6 @ cfa - 32 - 5 * vlenb
181+
; OMIT-FP-ZCMP-NEXT: .cfi_escape 0x10, 0x67, 0x0b, 0x11, 0x60, 0x22, 0x11, 0x7c, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22 # $v7 @ cfa - 32 - 4 * vlenb
182182
; OMIT-FP-ZCMP-NEXT: #APP
183183
; OMIT-FP-ZCMP-NEXT: #NO_APP
184184
; OMIT-FP-ZCMP-NEXT: csrr a0, vlenb

0 commit comments

Comments
 (0)