-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[RISCV] Fix typo in CV_SH_rr_inc pattern #120246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This typo caused a compiler crash in 'RISC-V Assembly Printer' because CV_SH_ri_inc was selected, leading to `getImmOpValue` being called for a register operand. This bug did not affect the Assembler output and therefore does not trigger any existing unit tests, but is visible by examining the final MIR function.
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-backend-risc-v Author: Philipp van Kempen (PhilippvK) ChangesThis typo in https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td#L701:L701 caused a compiler crash in 'RISC-V Assembly Printer' because CV_SH_ri_inc was selected, leading to This bug did not affect the Assembler output and therefore does not trigger any existing unit tests, but is visible by examining the final MIR function. I came up with a minimal test, but I am unsure how to integrate this into llvm/test/CodeGen/RISCV/xcvmem.ll while still using ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -O3 -mtriple=riscv32 -mattr=+xcvmem -verify-machineinstrs -stop-after=instruction-select < %s \
; RUN: | FileCheck %s --check-prefixes=CHECK_MIR
define i16* @<!-- -->sh_ri_inc(i16* %a, i16 %b) {
; CHECK_MIR: CV_SH_ri_inc
store i16 %b, i16* %a
%1 = getelementptr i16, i16* %a, i32 42
ret i16* %1
}
define i16* @<!-- -->sh_rr_inc(i16* %a, i16 %b, i32 %c) {
; CHECK_MIR: CV_SH_rr_inc
store i16 %b, i16* %a
%1 = getelementptr i16, i16* %a, i32 %c
ret i16* %1
} Full diff: https://github.com/llvm/llvm-project/pull/120246.diff 1 Files Affected:
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td b/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td
index 4478e246111080..b98934d8c63964 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td
@@ -698,7 +698,7 @@ let Predicates = [HasVendorXCVmem, IsRV32], AddedComplexity = 1 in {
def : CVStriPat<post_store, CV_SW_ri_inc>;
def : CVStrriPat<post_truncsti8, CV_SB_rr_inc>;
- def : CVStrriPat<post_truncsti16, CV_SH_ri_inc>;
+ def : CVStrriPat<post_truncsti16, CV_SH_rr_inc>;
def : CVStrriPat<post_store, CV_SW_rr_inc>;
def : CVStrrPat<truncstorei8, CV_SB_rr>;
|
You're almost right with your file header, but not quite. You need to make sure that the I'm not sure you can use |
…o::verifyInstruction. The generic verifier will do this if the operand type is OPERAND_IMMEDIATE, but we use our own custom operand types. Immediate operands are still allowed to be globals, constant pools, blockaddress, etc. so we can't check !isImm(). Fix the same typo as llvm#120246 which is now detected by this.
I just posted #120286 which I think removes the need to test MIR for this. If we agree, we can land just the .td change in this patch without any test and I'll land the verifier fix after. |
@lenary Thank you for the hint. I wanted to avoid adding a completely new set of test files for testing the XCV* extensions on the MIR level.
@topperc That actually sounds like the best solution. Your fix makes a lot of sense, thank you! Can I expect this fix to be backported to LLVM19.1.6? |
I think we can backport the .td change to 19.1.6. I'll have to check if my verifier patch can be backported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@PhilippvK I assume you need me to commit this? |
@topperc Yes, that would be great! |
@PhilippvK Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
/cherry-pick e8ce6c4 |
/pull-request #120296 |
This typo in https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td#L701:L701 caused a compiler crash in 'RISC-V Assembly Printer' because CV_SH_ri_inc was selected, leading to `getImmOpValue` being called for a register operand. This bug did not affect the Assembler output and therefore does not trigger any existing unit tests, but is visible by examining the final MIR function. (cherry picked from commit e8ce6c4)
This typo in https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td#L701:L701 caused a compiler crash in 'RISC-V Assembly Printer' because CV_SH_ri_inc was selected, leading to
getImmOpValue
being called for a register operand.This bug did not affect the Assembler output and therefore does not trigger any existing unit tests, but is visible by examining the final MIR function.
I came up with a minimal test, but I am unsure how to integrate this into llvm/test/CodeGen/RISCV/xcvmem.ll while still using
utils/update_llc_test_checks.py
. I would be happy I you could provide a hint on how bothCHECK_ASM
as well asCHECK_MIR
lines could be generated automatically in the same test.