[llvm] [AVR] Force relocations for non-encodable jumps (PR #121498)
Patryk Wychowaniec via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 9 12:59:33 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:
Unfortunately I'm unable to write such test:
- within MC tests, the `fixup_*` functions always witness zero for `Value`,
- within LDD tests I'm only able to trigger `relocation R_AVR_... out of range: ... is not in [..., ...]`.
I could use some more help with that.
https://github.com/llvm/llvm-project/pull/121498
More information about the llvm-commits
mailing list