Closed shepmaster closed 8 years ago
What's happening is that we are selecting the brne
instruction for a branch to basic block LBB0_9
. When assembling, this block just happens to be more than ~60 instruction away from the calling branch instruction, which is out of range of the 7-bit immediate of the brne
instruction.
We should be doing the same thing that AVR-GCC does and promote the brne LBB0_9
to:
brne next
next: jmp LBB0_9
From memory, I think this is called a landing pad.
From memory, I think this is called a landing pad.
I think I would have used trampoline. LLVM seems to use landing pad for exception handling, but it also has trampoline intrinsics, so that might not be the right phrase either. :-)
Have fixed this in a46a0aa9320d4e1cdbe812c221ff0f0925634c1d.
Confirmed here:
jake.o: file format elf32-avr
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
00000038 R_AVR_13_PCREL .text+0x0000010c
0000004a R_AVR_13_PCREL .text+0x000000d4
0000004c R_AVR_LO8_LDI byte_str28510
0000004e R_AVR_HI8_LDI byte_str28510
00000054 R_AVR_7_PCREL .text+0x000000d4
0000006c R_AVR_7_PCREL .text+0x0000007c
0000007a R_AVR_13_PCREL .text+0x0000008c
000000a2 R_AVR_CALL core_num_flt2dec_strategy_grisu
000000b2 R_AVR_CALL core_num_flt2dec_strategy_dragon
000000ba R_AVR_7_PCREL .text+0x000000d4
000000c0 R_AVR_7_PCREL .text+0x000000d4
000000d2 R_AVR_13_PCREL .text+0x000000dc
00000112 R_AVR_13_PCREL .text+0x0000003a
00000118 R_AVR_13_PCREL .text+0x0000003a
0000011e R_AVR_13_PCREL .text+0x0000003a
00000124 R_AVR_13_PCREL .text+0x0000003a
00000128 R_AVR_13_PCREL .text+0x0000003a
Compiling with
llc -march=avr < "$@" | llvm-mc -triple avr -mattr=avr6 -filetype=obj
, I'm getting the errorerror: out of range branch target (expected a integer in the range -128 to 127)
for this code:Sorry for the largeness of it, but I think that is integral to the problem.