[llvm] [AVR] Emit relocation record for local branch (PR #145291)

Tom Vijlbrief via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 24 03:38:17 PDT 2025


tomtor wrote:


@Patryk27 I updated one of the now failing tests:

For the ATTINY85 test the `brne .+2` is replaced by a `brne .-2` and a next line with the relocation (`+0x8` looks good).
The `.+2` makes no sense, but this isn't an issue because it is fixed when loading? I will check that, but it does not look very natural. The ` ; AVR3-NEXT: jmp 0x0` at the end is better, the `0x0` signalling that it is not yet known.

Before I proceed with editing the tests (a lot of them)

```
--- a/llvm/test/CodeGen/AVR/branch-relaxation-long-forward.ll
+++ b/llvm/test/CodeGen/AVR/branch-relaxation-long-forward.ll
@@ -5,15 +5,18 @@
 ; ATTINY85: <main>:
 ; ATTINY85-NEXT: andi r24, 0x1
 ; ATTINY85-NEXT: cpi r24, 0x0
-; ATTINY85-NEXT: brne .+2
-; ATTINY85-NEXT: rjmp .-4092
+; ATTINY85-NEXT: brne .-2
+; ATTINY85-NEXT: R_AVR_7_PCREL .text+0x8
+; ATTINY85-NEXT: rjmp .-2
+; ATTINY85-NEXT: R_AVR_13_PCREL .text+0x100c
 ; ATTINY85: ldi r24, 0x3
 ; ATTINY85-NEXT: ret

 ; AVR25: <main>:
 ; AVR25-NEXT: andi r24, 0x1
 ; AVR25-NEXT: cpi r24, 0x0
-; AVR25-NEXT: brne .+2
+; AVR25-NEXT: brne .-2
+; AVR25-NEXT: R_AVR_7_PCREL .text+0x8
 ; AVR25-NEXT: rjmp .-2
 ; AVR25-NEXT: R_AVR_13_PCREL .text+0x100c
 ; AVR25: ldi r24, 0x3
@@ -22,7 +25,8 @@
 ; AVR3: <main>:
 ; AVR3-NEXT: andi r24, 0x1
 ; AVR3-NEXT: cpi r24, 0x0
-; AVR3-NEXT: brne .+4
+; AVR3-NEXT: brne .-2
+; AVR3-NEXT: R_AVR_7_PCREL .text+0xa
 ; AVR3-NEXT: jmp 0x0
 ; AVR3-NEXT: R_AVR_CALL .text+0x100e
 ; AVR3: ldi r24, 0x3
```

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


More information about the llvm-commits mailing list