Function MipsAsmParser::expandMemInst() did not properly handle instruction sc
with a symbol as an argument because first argument would be counted twice.
We add additional checks and handle this case separately.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
I cannot invent any negative test case / example, but I'm concerned a bit that we completely drop information about out-register. The sc instruction has output result but we do not track that fact in td file just in our mind.
Alternative solution that does not remove out-register would look something like this: https://reviews.llvm.org/differential/diff/211116/
- Decided to apply diff of the alternative solution because the patch could not be downloaded with just the provided diff.
test/MC/Mips/sym-sc.s | ||
---|---|---|
51 ↗ | (On Diff #211524) | Could you modify this test case or add a new one to check handling symbol and offset? Like this sc $12, some_random_symbol_name + 8. |
Symbol with offset was not handled properly on MipsR6. R_MIPS_LO16 (MipsMCExpr::MEK_LO) would write offset into lower 16 bits, where as for R6 version offset is in bits 7-15. Initially I made new type of MCFixup which would only use those bits, but then there was a lot of additional code needed for handling all cases where MCFixups were used. Now we just add ADDIU for R6 and use R_MIPS_LO16 on that instruction which is the same way that gcc works.