-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[llvm][ARM] Allow MOVT and MOVW on the offset between two labels #168072
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
In this case, the value is a constant, not an addend to a relocation. So the "Relocation Not In Range" error must not be triggered. Regression from PR llvm#112877 Fixes llvm#132322
|
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-arm Author: Loïc Yhuel (hwti) ChangesIn this case, the value is a constant, not an addend to a relocation. Regression from PR #112877 Full diff: https://github.com/llvm/llvm-project/pull/168072.diff 2 Files Affected:
diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
index f8196e460ae9c..02a7b1a3d0919 100644
--- a/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
+++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
@@ -428,7 +428,7 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCAssembler &Asm,
// signed 16bit range.
if ((Kind == ARM::fixup_arm_movw_lo16 || Kind == ARM::fixup_arm_movt_hi16 ||
Kind == ARM::fixup_t2_movw_lo16 || Kind == ARM::fixup_t2_movt_hi16) &&
- (Addend < minIntN(16) || Addend > maxIntN(16))) {
+ !Target.isAbsolute() && (Addend < minIntN(16) || Addend > maxIntN(16))) {
Ctx.reportError(Fixup.getLoc(), "Relocation Not In Range");
return 0;
}
diff --git a/llvm/test/MC/ARM/arm-movt-movw-absolute-pass.s b/llvm/test/MC/ARM/arm-movt-movw-absolute-pass.s
new file mode 100644
index 0000000000000..ed888a0a4aaae
--- /dev/null
+++ b/llvm/test/MC/ARM/arm-movt-movw-absolute-pass.s
@@ -0,0 +1,14 @@
+@RUN: llvm-mc -triple armv7-eabi -filetype obj -o - %s 2>&1 | FileCheck %s
+
+ .text
+a:
+ movw r1, #:lower16:b - a + 65536
+ movt r1, #:upper16:b - a + 65536
+b:
+
+@CHECK-NOT: error: Relocation Not In Range
+@CHECK-NOT: movw r1, #:lower16:b - a + 65536
+@CHECK-NOT: ^
+@CHECK-NOT: error: Relocation Not In Range
+@CHECK-NOT: movt r1, #:upper16:b - a + 65536
+@CHECK-NOT: ^
|
|
cc @Stylie777 @DavidSpickett @jthackray from the PR which added the |
| movt r1, #:upper16:b - a + 65536 | ||
| b: | ||
|
|
||
| @CHECK-NOT: error: Relocation Not In Range |
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.
Instead of checking for the error message, please just check that we generate the correct instruction encoding.
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.
I used arm-movt-movw-range-pass.s as a model.
llvm-mc -show-encoding produces :
movw r1, :lower16:((b-a)+65536) @ encoding: [A,0x10'A',0b0000AAAA,0xe3]
@ fixup A - offset: 0, value: (b-a)+65536, kind: fixup_arm_movw_lo16
movt r1, :upper16:((b-a)+65536) @ encoding: [A,0x10'A',0b0100AAAA,0xe3]
@ fixup A - offset: 0, value: (b-a)+65536, kind: fixup_arm_movt_hi16
so it doesn't show the value is resolved.
Do you want a test with llvm-objdump, like :
@RUN: llvm-mc -triple armv7-eabi -filetype obj %s -o - | llvm-objdump -d --triple armv7-eabi - | FileCheck %s
a:
movw r1, #:lower16:b - a + 65536
movt r1, #:upper16:b - a + 65536
b:
@CHECK: 0: e3001008 movw r1, #0x8
@CHECK: 4: e3401001 movt r1, #0x1
?
But it actually tests more, so I don't know know if you meant with "just check ...".
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.
Something with llvm-objdump seems fine, yes.
| if ((Kind == ARM::fixup_arm_movw_lo16 || Kind == ARM::fixup_arm_movt_hi16 || | ||
| Kind == ARM::fixup_t2_movw_lo16 || Kind == ARM::fixup_t2_movt_hi16) && | ||
| (Addend < minIntN(16) || Addend > maxIntN(16))) { | ||
| !Target.isAbsolute() && (Addend < minIntN(16) || Addend > maxIntN(16))) { |
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.
Maybe could use IsResolved here instead? I guess it's basically the same thing in this context.
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.
OK, changed to !IsResolved.
🐧 Linux x64 Test Results
|
efriedma-quic
left a comment
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
|
@hwti 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! |
In this case, the value is a constant, not an addend to a relocation.
So the "Relocation Not In Range" error must not be triggered.
Regression from PR #112877
Fixes #132322