Repository navigation
[finding - write your own PR title] loongarch: vstelm/xvstelm detail uses the offset immediate as the memory base register - #3150
Closed
Samin061 wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #3150 +/- ##
=======================================
Coverage ? 61.45%
=======================================
Files ? 243
Lines ? 56829
Branches ? 10077
=======================================
Hits ? 34925
Misses ? 16708
Partials ? 5196 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
This clearly violates the AI guidelines |
Collaborator
|
Indeed, it does. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NOTE FOR THE ACCOUNT OWNER (do not publish this text as-is): capstone-engine/capstone forbids AI-written PR descriptions and commit messages (CONTRIBUTING.md, "AI guidelines"; the PR template repeats it). Before publishing, (1) rewrite the commit subject in your own words with
git commit --amend(current placeholder subject: "loongarch: fix vstelm/xvstelm memory operand detail"), and (2) write the PR body yourself using the repository template (.github/PULL_REQUEST_TEMPLATE.md: checklist, Detailed description, Test plan, Closing issues). Keep it short; the maintainer (Rot127) has asked for brief descriptions. The AI guidelines allow AI for the code itself, so disclose AI assistance in one sentence in your own words. Facts to draw from:Where: LoongArch_rewrite_memory_operand() in arch/LoongArch/LoongArchMapping.c. The vstelm.{b,h,w,d} and xvstelm.{b,h,w,d} instructions (forms FMT2RI8I*_VRII and FMT2RI8I*_XRII) have four operands: vd/xd, rj, si8 offset, element index. The function grouped them with the three-operand base+offset loads/stores and rewrote operand[-2], which for these instructions is the si8 immediate, into the LOONGARCH_OP_MEM operand. The immediate value therefore became mem.base and the element index became mem.disp.
Effect: cs_detail reports an invalid register id as the memory base (e.g. 214 for
xvstelm.h $xr26, $t4, 0xd6, 1, bytes 1a ae 45 33, CS_MODE_LOONGARCH64) and lists it in regs_read via cs_regs_access. cs_reg_name() returns NULL for it in release builds; in Debug builds the getRegisterName() assert aborts (cstool and any consumer calling cs_reg_name on the reported id). Reproduce with: cstool -d loongarch64 "1a ae 45 33" (Debug build aborts with "RegNo && RegNo < 177"; release build prints mem.base = (null)).Fix: handle the eight *stelm forms in their own case: rj (operand[-3]) becomes the memory operand with disp = si8, the element index moves down one slot, op_count is decremented. A sweep of the generated mapping shows these eight forms are the only four-operand memory forms that took the generic path (sc.q, llacq, screl were already special-cased).
Tests: regression cases for xvstelm.h and vstelm.b added to tests/details/loongarch.yaml (fail before the fix: regs_read_count 3 != 2; pass after). Locally run: cstest tests/details (DetailTests), tests/MC/LoongArch (1207 cases), ctest MCTests/IssueTests/FeaturesTests/NegativeTests/unit_/integration_ all pass on a Debug build; clang-format clean; git diff --check clean.