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

Ben Shi via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 2 21:53:04 PST 2025


================
@@ -512,14 +535,25 @@ bool AVRAsmBackend::writeNopData(raw_ostream &OS, uint64_t Count,
 bool AVRAsmBackend::shouldForceRelocation(const MCAssembler &Asm,
                                           const MCFixup &Fixup,
                                           const MCValue &Target,
+                                          const uint64_t Value,
                                           const MCSubtargetInfo *STI) {
   switch ((unsigned)Fixup.getKind()) {
   default:
     return Fixup.getKind() >= FirstLiteralRelocationKind;
+
   case AVR::fixup_7_pcrel:
-  case AVR::fixup_13_pcrel:
-    // Always resolve relocations for PC-relative branches
-    return false;
+  case AVR::fixup_13_pcrel: {
+    uint64_t ValueEx = Value;
+    uint64_t Size = AVRAsmBackend::getFixupKindInfo(Fixup.getKind()).TargetSize;
+
+    // If the jump is too large to encode it, fall back to a relocation.
----------------
benshi001 wrote:

I do not think this is a good change, since llvm-avr does not serve rustc only. I think it would be better to report 'out of range' as early as possible, than postpone to linking phase.

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


More information about the llvm-commits mailing list