This patch fixes the inaccurate decoding of the offset operand of
the RCALL & RJMP instructions.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Shouldn't this also affect llvm/test/MC/AVR/inst-rjmp.s?
In any case, I think it's better to (also) have tests in llvm/test/MC/AVR for this.
Actually this bug does not affect llvm/test/MC/AVR/inst-rjmp.s, so I can not add any test in llvm/test/MC/AVR.
Since llvm-objdump decodes all address offsets of rjmp/rcall (before linking) to 0, so you can see those zeros in llvm/test/MC/AVR/inst-rjmp.s, which are not affected.
llvm-objdump only affects address offsets of rjmp/rcall that are after linking, so we have to test them in the lld tests.
llvm/lib/Target/AVR/Disassembler/AVRDisassembler.cpp | ||
---|---|---|
300 | This is modified by clang-format . |
Hmm, yeah that's a problem.
@MaskRay do you have an idea how to properly test this? I don't like moving these tests into lld (it's a separate subproject), but the alternative seems to be to use a binary file to test against which isn't great either.
I do see many .o files in clang/test/, but none in llvm/test/MC/ . Do we need to create such a precedent ?
llvm-objdump only affects address offsets of rjmp/rcall that are after linking, so we have to test them in the lld tests.
It's not appropriate to add a lld test to test an assembly issue (https://maskray.me/blog/2021-08-08-toolchain-testing#the-test-checks-at-the-wrong-layer). Such tests live in llvm/test/MC/
If you want to disassembly an arbitrary instruction, you may use directives like .word: after disassembly, an instruction isn't differentiable with a .word xxx.
If you want to craft an ET_EXEC or ET_DYN file, use yaml2obj. See llvm/test/tools/llvm-{objcopy,readobj} for some examples.
You can use llvm-readelf -x ... to dump the content of a section.
llvm/test/MC/AVR/inst-rjmp.s | ||
---|---|---|
49 | The positive offset is tested here and the negative offset is tested in inst-rcall.s. |
That's indeed a nice solution, didn't think of that!
llvm/test/MC/AVR/inst-rcall.s | ||
---|---|---|
13 | It may be useful for the reader to add what this means: .short 0xdfea ; rcall .-44 |
This is modified by clang-format .