avr-llvm / llvm

[MERGED UPSTREAM] AVR backend for the LLVM compiler library
220 stars 21 forks source link

Add AVRPromoteBranches pass #210

Closed dylanmckay closed 8 years ago

dylanmckay commented 8 years ago

Will fix #209.

dylanmckay commented 8 years ago

After doing a lot of the work for this, I realised that this is why AVR-GCC never resolves branch fixups during compilation time and instead promotes them all to ELF relocations in the object file.

This means that the linker will be able to make this decision. I believe this is what we should also do.

The way I implemented this was also tricky because there wasn't really any information about where the code will be in memory at this stage in the pipeline. This is inevitably a solution that should be done in the linker.

shepmaster commented 8 years ago

promotes them all to ELF relocations in the object file.

be done in the linker.

Does the linker then understand that certain instructions have limits, but that it's optimal to use them when it can? Or will everything become a branch to a jump?

dylanmckay commented 8 years ago

Does the linker then understand that certain instructions have limits, but that it's optimal to use them when it can? Or will everything become a branch to a jump?

It understands the limits, and only turn branches into trampolines if they are out of bounds.