[llvm] [AVR] Force relocations for non-encodable jumps (PR #121498)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 9 21:11:14 PST 2025
================
@@ -31,60 +31,48 @@ 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;
-
- 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);
+static bool checkUnsignedWidth(unsigned Width, uint64_t Value,
+ Twine Description, const MCFixup &Fixup,
+ MCContext *Ctx) {
+ if (isUIntN(Width, Value)) {
+ return true;
}
-}
-
-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;
+ 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(),
+ Twine("out of range ") + Description +
+ " (expected an integer in the range 0 to " +
+ Twine(Max) + ")");
}
+
+ return false;
}
/// Adjusts the value of a branch target before fixup application.
static void adjustBranch(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
MCContext *Ctx) {
// We have one extra bit of precision because the value is rightshifted by
// one.
- unsigned_width(Size + 1, Value, std::string("branch target"), Fixup, Ctx);
+ checkUnsignedWidth(Size + 1, Value, std::string("branch target"), Fixup, Ctx);
----------------
arsenm wrote:
No std::string
https://github.com/llvm/llvm-project/pull/121498
More information about the llvm-commits
mailing list