A callee save may be live (specifically X1) on entry and so a spill should not mark it killed.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
An example of incorrect code in baseline is below where the spill of X1 is marked killed but is live to the following SW.
Function Live Ins: $x1 bb.0.entry: liveins: $x1 $x2 = frame-setup ADDI $x2, -32 CFI_INSTRUCTION def_cfa_offset 32 SD killed $x1, $x2, 24 SD killed $x8, $x2, 16 CFI_INSTRUCTION offset $x1, -8 CFI_INSTRUCTION offset $x8, -16 $x8 = frame-setup ADDI $x2, 32 CFI_INSTRUCTION def_cfa $x8, 0 SW killed renamable $x1, $x8, -20 :: (store 4 into %ir.a)
I believe:
declare void @callee(i8**) define void @caller() nounwind { %1 = alloca i8* %2 = call i8* @llvm.returnaddress(i32 0) store i8* %2, i8** %1 call void @callee(i8** %1) ret void }
with -stop-after=prologepilog should work. Or perhaps better to take the MIR for that with -stop-before=prologepilog and run just prologepilog on it in the test.
Seems fine now. Any other comments? @craig.topper @jrtc27
llvm/test/CodeGen/RISCV/live_sp.mir | ||
---|---|---|
4–8 ↗ | (On Diff #377972) | Nit: remove this and add -march=riscv64 in RUN line instead? |
This looks good to me., thanks you! Very minor nits on the test file:
- I agree with Luis that modifying to use -march would be marginally better (you no longer need to worry if the datalayout string is the current standard RISC-V one for instance)
- Although a comment linking to this review thread doesn't make sense, it would probably be helpful to add a comment to note that the live X1 register isn't incorrectly marked as killed when being spilled.
@luke957 your Herald rule seems to automatically add you as a blocking reviewer - could you please adjust it. It would probably be best to just have the rule add you as a subscriber.
I made the two tweaks suggested but as it turns out I can't commit to github, can someone land this for me?