This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Expand PseudoTAIL with t2 instead of t1 for Zicfilp.
Needs ReviewPublic

Authored by fakepaper56 on Aug 16 2023, 7:24 PM.

Details

Summary

PseudoTail should be a software guarded branch in Ziciflp, since its branch
target is known in link time. JALR/C.JR/C.JALR with rs1 as t2 is termed a
software guarded branch. Such branches do not need to land on a lpad instruction.

Diff Detail

Unit TestsFailed

Event Timeline

fakepaper56 created this revision.Aug 16 2023, 7:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 16 2023, 7:24 PM
fakepaper56 requested review of this revision.Aug 16 2023, 7:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 16 2023, 7:24 PM

https://github.com/riscv-non-isa/riscv-asm-manual/blob/master/riscv-asm.md#-a-listing-of-standard-risc-v-pseudoinstructions very clearly states that x6 is the register used. What's wrong with t1? x1 and x5 are special as the registers for microarchitectural push/pop hints and, with Zicfilp, repurposed for shadow stack push/pop (somewhat ew), but neither x6 nor x7 are mentioned in the CFI spec that I can see.

Oh I see, https://github.com/riscv/riscv-cfi/blob/main/cfi_forward.adoc does. Why on earth did they pick x7 for tail when x6 is the register defined for tail?

Is it because x7 is the landing pad label? So if the call used x7 as the address then its clearly does not contain a landing pad label? I'm just guessing.

Is it because x7 is the landing pad label? So if the call used x7 as the address then its clearly does not contain a landing pad label? I'm just guessing.

So why not make x6 the landing pad label if they want everything to be in one register...

Is it because x7 is the landing pad label? So if the call used x7 as the address then its clearly does not contain a landing pad label? I'm just guessing.

So why not make x6 the landing pad label if they want everything to be in one register...

Software guarded branches changed to x6 here https://github.com/riscv/riscv-cfi/commit/aaea3077bc4256dd56b07403cd1b88ca46b83c27 but then changed back https://github.com/riscv/riscv-cfi/commit/afbc2d5544f8ceda4a69d4c1ba17efc7c2c639d3

Is it because x7 is the landing pad label? So if the call used x7 as the address then its clearly does not contain a landing pad label? I'm just guessing.

So why not make x6 the landing pad label if they want everything to be in one register...

Software guarded branches changed to x6 here https://github.com/riscv/riscv-cfi/commit/aaea3077bc4256dd56b07403cd1b88ca46b83c27 but then changed back https://github.com/riscv/riscv-cfi/commit/afbc2d5544f8ceda4a69d4c1ba17efc7c2c639d3

I found as much, but not any justification for these changes anywhere, just unhelpful commits that don't document any rationale.

https://github.com/riscv/riscv-cfi/issues/125#issuecomment-1686258580
In this comment, Ved says that x6/t1 plays an ABI role in passing information between the PLT header and the dynamic linker.

https://github.com/riscv/riscv-cfi/issues/125#issuecomment-1686258580
In this comment, Ved says that x6/t1 plays an ABI role in passing information between the PLT header and the dynamic linker.

Which is irrelevant for the register to jump via