-
Notifications
You must be signed in to change notification settings - Fork 13k
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
[AArch64] Fix movk parsing with an .equ operand #124428
Conversation
Prior to 5da8013, this code worked: .equ p4_low_b0, 0x0000 movk x1, p4_low_b0, lsl 16 That commit fixed a different bug, but accidentally broke the case where the second operand to movk is not a literal. In 442f066, a fix was applied to handle the case where the second operand is a value like "(Val) >> 16". However, that didn't appear to fix the test case in this commit. In this commit, we extend the change to handle the case where the second operand is a identifier defined by .equ.
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-mc @llvm/pr-subscribers-backend-aarch64 Author: Palmer (DaGenix) ChangesPrior to 5da8013, this code worked:
That commit fixed a different bug, but accidentally broke the case where the second operand to movk is not a literal. In 442f066, a fix was applied to handle the case where the second operand is a value like "(Val) >> 16". However, that didn't appear to fix the test case in this commit. In this commit, we extend the change to handle the case where the second operand is a identifier defined by .equ. Fixes #124427 I do not understand the code super well - I extended the existing fix and it appears to work / passes all tests that I ran. I'm not 100% sure where to add a test case. I added it to the best file that seemed to make sense to me, but it could be the wrong place. Even if its the wrong place, it does appear to test the fix - it fails without the fix and passes with it. Full diff: https://github.com/llvm/llvm-project/pull/124428.diff 2 Files Affected:
diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
index d3eda48f3276e9..27b052825d2133 100644
--- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -5017,7 +5017,9 @@ bool AArch64AsmParser::parseOperand(OperandVector &Operands, bool isCondCode,
return true;
E = SMLoc::getFromPointer(getLoc().getPointer() - 1);
Operands.push_back(AArch64Operand::CreateImm(IdVal, S, E, getContext()));
- return false;
+
+ // Parse an optional shift/extend modifier.
+ return parseOptionalShiftExtend(getTok());
}
case AsmToken::Integer:
case AsmToken::Real:
diff --git a/llvm/test/MC/AArch64/arm64-basic-a64-instructions.s b/llvm/test/MC/AArch64/arm64-basic-a64-instructions.s
index 2f58eadfc8462c..5af4140b3e4101 100644
--- a/llvm/test/MC/AArch64/arm64-basic-a64-instructions.s
+++ b/llvm/test/MC/AArch64/arm64-basic-a64-instructions.s
@@ -16,3 +16,6 @@
// CHECK: crc32ch w13, w17, w25 // encoding: [0x2d,0x56,0xd9,0x1a]
// CHECK: crc32cw wzr, w3, w5 // encoding: [0x7f,0x58,0xc5,0x1a]
// CHECK: crc32cx w18, w16, xzr // encoding: [0x12,0x5e,0xdf,0x9a]
+
+ .equ p4_low_b0, 0x0000
+ movk x1, p4_low_b0, lsl 16
|
FYI: @MaskRay |
The tests are not very well-organized. I might use rg to find relevant tests
Perhaps use basic-a64-instructions.s in the absence of better tests. Use a non-zero constant (e.g. |
Thanks, @MaskRay! I moved the test to the file you suggested. |
Thanks for reviewing, @MaskRay! I'm a first time contributor and unable to merge - are you able to merge this? |
@DaGenix 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! |
Thanks, @MaskRay ! |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/64/builds/2097 Here is the relevant piece of the build log for the reference
|
Prior to 5da8013, this code worked:
(The code above is from the isa-l project - I discovered this issue while trying to compile it with clang 19 on MacOS on aarch64)
That commit fixed a different bug, but accidentally broke the case where the second operand to movk is not a literal.
In 442f066, a fix was applied to handle the case where the second operand is a value like "(Val) >> 16". However, that didn't appear to fix the test case in this commit. In this commit, we extend the change to handle the case where the second operand is a identifier defined by .equ.
Fixes #124427
I do not understand the code super well - I extended the existing fix and it appears to work / passes all tests that I ran.
I'm not 100% sure where to add a test case. I added it to the best file that seemed to make sense to me, but it could be the wrong place. Even if its the wrong place, it does appear to test the fix - it fails without the fix and passes with it.