fix AArch64 predicate-as-counter register printed in hex#2976
Open
yufengzjj wants to merge 1 commit into
Open
Conversation
Collaborator
Yes, this is one of the shortcomings of testing I added because I didn't want to fix all the old tests I just moved. |
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.
Your checklist for this pull request
Detailed description
AArch64 predicate-as-counter registers
pn10–pn15were printed in hexadecimal(e.g.
ptrue pn0xa.hinstead ofptrue pn10.h).The cause is in the
printPredicateAsCountermacro inarch/AArch64/AArch64InstPrinter.c.It printed the register index via
printUInt32(), which automatically switches to a0x%xhex representation once the value exceedsHEX_THRESHOLD(defined as9inutils.h):So pn0–pn9 printed correctly, but the index 10–15 (registers pn10–pn15)
was rendered as 0xa–0xf.
The register number must always be printed in decimal, matching upstream LLVM
(O << "pn" << (Reg - AArch64::PN0)). The fix prints the index directly in decimal
instead of routing it through the hex-thresholding helper:
SStream_concat(O, "%s", "pn");
This is a one-line, output-only change; the decoded register value/detail is unaffected.
Test plan
Added a regression test case to tests/issues/issues.yaml for ptrue pn10.h
(bytes [0x12, 0x78, 0x60, 0x25]).
Important
the test runners (cstest / cstest_py) normalize hex numbers to decimal when
comparing asm_text (see replace_hex() in suite/cstest/src/helper.c and
normalize_asm_text() in cstest_py), so an asm_text-only check passes even with the
bug present(e.g. tests\MC\AArch64\SVE2p1\ptrue.s.yaml).
To make the test actually catch the regression, the expected op_str field
is set explicitly (op_str: "pn10.h").
Verified locally with cstest/cstest_py
Also confirmed via cstool directly
Closing issues
#2973