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

Patryk Wychowaniec via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 5 00:32:02 PST 2025


================
@@ -60,31 +70,37 @@ static void unsigned_width(unsigned Width, uint64_t Value,
 
     Ctx->reportError(Fixup.getLoc(), Diagnostic);
   }
+
+  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);
 
   // Rightshifts the value by one.
   AVR::fixups::adjustBranchTarget(Value);
 }
 
 /// Adjusts the value of a relative branch target before fixup application.
-static void adjustRelativeBranch(unsigned Size, const MCFixup &Fixup,
-                                 uint64_t &Value, MCContext *Ctx) {
+static bool adjustRelativeBranch(unsigned Size, const MCFixup &Fixup,
+                                 uint64_t &Value, MCContext *Ctx,
+                                 const MCSubtargetInfo *STI = nullptr) {
   // Jumps are relative to the current instruction.
   Value -= 2;
 
   // We have one extra bit of precision because the value is rightshifted by
   // one.
   Size += 1;
 
-  if (!isIntN(Size, Value) &&
-      Ctx->getSubtargetInfo()->hasFeature(AVR::FeatureWrappingRjmp)) {
+  if (!STI) {
----------------
Patryk27 wrote:

> The subtarget is a function level concept

I don't think so, you specify the subtarget when you run `llc`, it's also explicitly mentioned in `MCAsmBackendCtorTy` etc., no?

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


More information about the llvm-commits mailing list