From 29828b26fac3ee744c8f7dcb33cc082dc7c00a02 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Mon, 25 Nov 2024 10:03:48 -0800 Subject: [PATCH] [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. --- llvm/lib/Target/RISCV/RISCVFrameLowering.cpp | 3 +-- llvm/test/CodeGen/RISCV/rvv/rvv-cfi-info.ll | 14 +++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp index 1ff435b76ad6..a0fdf77cb0c0 100644 --- a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp @@ -1758,8 +1758,7 @@ void RISCVFrameLowering::emitCalleeSavedRVVPrologCFI( if (!HasFP) { uint64_t ScalarLocalVarSize = MFI.getStackSize() - RVFI->getCalleeSavedStackSize() - - RVFI->getRVPushStackSize() - RVFI->getVarArgsSaveSize() + - RVFI->getRVVPadding(); + RVFI->getVarArgsSaveSize() + RVFI->getRVVPadding(); FixedSize -= ScalarLocalVarSize; } diff --git a/llvm/test/CodeGen/RISCV/rvv/rvv-cfi-info.ll b/llvm/test/CodeGen/RISCV/rvv/rvv-cfi-info.ll index 917df53911c4..0ae2c2ef9c9d 100644 --- a/llvm/test/CodeGen/RISCV/rvv/rvv-cfi-info.ll +++ b/llvm/test/CodeGen/RISCV/rvv/rvv-cfi-info.ll @@ -172,13 +172,13 @@ define riscv_vector_cc @test_vector_callee_cfi(