Skip to content

[InstrRef] Fix mismatch between LiveDebugValues and salvageCopySSA #124233

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

Merged
merged 1 commit into from
Jan 27, 2025

Conversation

rastogishubham
Copy link
Contributor

@rastogishubham rastogishubham commented Jan 24, 2025

The LiveDebugValues pass and the instruction selector (which calls salvageCopySSA) need to be consistent on what they consider a copy instruction. With #75184, the definition of what a copy instruction is was narrowed for AArch64 to exclude a w->x ORR and treat it as a zero-extend rather than a copy

However, to make sure LiveDebugValues still treats a w->x ORR as a copy, the new function, isCopyLikeInstr was created. We need to make sure that salvageCopySSA also calls that function.

This patch addresses this mismatch.

The LiveDebugValues pass and the instruction selector (which calls)
salvageCopySSA need to be consistent on what they consider a copy
instruction. With llvm#75184, the
definition of what a copy instruction is was narrowed for AArch64 to
exclude a w->x ORR and treat it as a zero-extend rather than a copy

However, to make sure LiveDebugValues still treats a w->x ORR as a copy,
the new function, isCopyLikeInstr was created. We need to make sure that
salvageCopySSA also calls that function.

This patch addresses this mismatch.
@rastogishubham
Copy link
Contributor Author

rastogishubham commented Jan 24, 2025

Since nothing breaks currently and I am able to bootstrap build clang with instruction referencing turned on, on AArch64, I was unable to come up with a testcase for this, I am not the best at writing MIR by hand, and we would need an ORR which translates to a W register being ORRed with the zero register and being written to an X register. Not sure how to do that. Any advice would be really appreciated, thank you!

Copy link
Member

@jmorse jmorse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; I think we can skip writing a test as the failure isn't really an illegal output from the compiler, it's an inconsistency between the way these two passes are implemented. We might test certain things are considered copies, but it'd be exhausting to test that everything considered a copy by salvageCopySSA is considered a copy by LiveDebugValues.

A bigger question is "how do we prevent this happening in the future", and I'm not sure we need to as (IIRC) these are the only two parts of instr-ref that care about copies.

@rastogishubham rastogishubham merged commit 44c9e46 into llvm:main Jan 27, 2025
9 checks passed
@rastogishubham rastogishubham deleted the FixDiff branch January 27, 2025 17:26
rastogishubham added a commit to rastogishubham/llvm-project that referenced this pull request Jan 27, 2025
…lvm#124233)

The LiveDebugValues pass and the instruction selector (which calls
salvageCopySSA) need to be consistent on what they consider a copy
instruction. With llvm#75184, the
definition of what a copy instruction is was narrowed for AArch64 to
exclude a w->x ORR and treat it as a zero-extend rather than a copy

However, to make sure LiveDebugValues still treats a w->x ORR as a copy,
the new function, isCopyLikeInstr was created. We need to make sure that
salvageCopySSA also calls that function.

This patch addresses this mismatch.

(cherry picked from commit 44c9e46)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants