[llvm] [AVR] Force relocations for non-encodable jumps (PR #121498)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 9 01:31:10 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(),
----------------
arsenm wrote:

You can write an assembler test and there are various directives you can use to get a lot of binary padding, like .align and .fill 

https://github.com/llvm/llvm-project/pull/121498


More information about the llvm-commits mailing list