RISCVPushPopOptimizer.cpp combine cm.pop and ret to generates cm.popretz or cm.popret .
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Target/RISCV/RISCVInstrInfo.h | ||
---|---|---|
134 ↗ | (On Diff #521526) | Could we just use isCopyInstrImpl instead? |
llvm/lib/Target/RISCV/RISCVInstrInfo.h | ||
---|---|---|
134 ↗ | (On Diff #521526) | Agreed. Can we use isCopyInstrImpl and check for a copy from X0? |
llvm/lib/Target/RISCV/RISCVPushPopOptimizer.cpp | ||
42 | RetVal map should be capitalized. And this should probably be a DenseMap. | |
135 | use Fn.getSubtarget<RISCVSubtarget> | |
136 | Drop curly braces | |
140 | The line break in this comment should be closer to column 80. | |
141 | How does it break the ABI? | |
142 | Drop curly braces | |
158 | If it's not a return block, and adjustRetVal deletes the LI instruction, where does the return value go? | |
llvm/lib/Target/RISCV/RISCVTargetMachine.cpp | ||
351 | Should this be skipped at -O0? |
llvm/lib/Target/RISCV/RISCVPushPopOptimizer.cpp | ||
---|---|---|
32 | Subtarget doesn't need to be a member. It's only used in runOnMachineFunction | |
41 | Capitalize variable names | |
70 | Why does this need to be map? This function and adjustRetVal are called on the same basic block. There can't be values for any other basic block in the map. You could probably just pass the bool result from adjustRetVal to this function? | |
75 | If the value exists, it must be zero right? | |
108 | Isn't MI.getOperand(2).getImm() == 0 guaranteed by TII->isCopyInstrImpl(MI)? | |
141 | This question was not answered. | |
150 | I think you need to know the terminator is PseudoRET before you can call adjustRetVal. PseudoTAIL, PseudoTAILIndirect, SRET, and MRET also have isReturn but are not eligible for usePopRet. |
llvm/lib/Target/RISCV/RISCVPushPopOptimizer.cpp | ||
---|---|---|
141 |
llvm/lib/Target/RISCV/RISCVPushPopOptimizer.cpp | ||
---|---|---|
141 | As far as I can tell, this patch just fuses the cm.pop with ret. Wouldn't the ABI break occur at the creation of cm.pop not at the formation of cm.popret? |
llvm/lib/Target/RISCV/RISCVPushPopOptimizer.cpp | ||
---|---|---|
141 | Yes, using cm.push/pop is the issue, not fusing ones that already exist. Haven't looked at the content of the patch other than the few lines of context here. |
llvm/lib/Target/RISCV/RISCVPushPopOptimizer.cpp | ||
---|---|---|
141 | it was mentioned here https://github.com/plctlab/llvm-project/issues/58 , | |
141 | yes, So you can find the same code in the patch D134599#change-ZdluzfeA7hef This code here is just a quick exit if it doesn't match the condition | |
150 | Yeah you are right, that's why I have whether NextI->getOpcode() == RISCV::PseudoRET at func adjustRetVal. I will move it to here ) |
llvm/lib/Target/RISCV/RISCVPushPopOptimizer.cpp | ||
---|---|---|
141 |
Sorry for late reply, I forgot to submit it |
llvm/lib/Target/RISCV/RISCVPushPopOptimizer.cpp | ||
---|---|---|
68 | Can we do? unsigned Opc = IsReturnZero ? RISCV::CM_POPRETZ : RISCV::CM_POPRET; BuildMI(*NextI->getParent(), NextI, DL, TII->get(Opc)) .add(MBBI->getOperand(0)) .add(MBBI->getOperand(1)); |
Subtarget doesn't need to be a member. It's only used in runOnMachineFunction