[llvm] [AVR] Force relocations for non-encodable jumps (PR #121498)
Patryk Wychowaniec via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 9 01:08:24 PST 2025
================
@@ -31,60 +31,72 @@ namespace adjust {
using namespace llvm;
-static void signed_width(unsigned Width, uint64_t Value,
- std::string Description, const MCFixup &Fixup,
- MCContext *Ctx) {
- if (!isIntN(Width, Value)) {
- std::string Diagnostic = "out of range " + Description;
+static bool checkSignedWidth(unsigned Width, uint64_t Value,
+ std::string Description, const MCFixup &Fixup,
+ MCContext *Ctx) {
+ if (isIntN(Width, Value)) {
+ return true;
+ }
+ if (Ctx) {
int64_t Min = minIntN(Width);
int64_t Max = maxIntN(Width);
- Diagnostic += " (expected an integer in the range " + std::to_string(Min) +
- " to " + std::to_string(Max) + ")";
-
- Ctx->reportError(Fixup.getLoc(), Diagnostic);
+ Ctx->reportError(Fixup.getLoc(), Twine("out of range ") + Description +
+ " (expected an integer in the range " +
+ Twine(Min) + " to " + Twine(Max) +
+ ")");
}
+
+ return false;
}
-static void unsigned_width(unsigned Width, uint64_t Value,
- std::string Description, const MCFixup &Fixup,
- MCContext *Ctx) {
- if (!isUIntN(Width, Value)) {
- std::string Diagnostic = "out of range " + Description;
+static bool checkUnsignedWidth(unsigned Width, uint64_t Value,
+ std::string Description, const MCFixup &Fixup,
+ MCContext *Ctx) {
+ if (isUIntN(Width, Value)) {
+ return true;
+ }
+ if (Ctx) {
int64_t Max = maxUIntN(Width);
- Diagnostic +=
- " (expected an integer in the range 0 to " + std::to_string(Max) + ")";
-
- Ctx->reportError(Fixup.getLoc(), Diagnostic);
+ Ctx->reportError(Fixup.getLoc(),
----------------
Patryk27 wrote:
Any idea how to test it?
This is called mostly for `adjust_call()`, but since that instruction takes a 22-bit offset, we can't use the same test-trick with repeated `call void asm sideeffect "nop", ""()` that we use for `branch-relaxation*.ll`.
https://github.com/llvm/llvm-project/pull/121498
More information about the llvm-commits
mailing list