From fd64bd94eda0b93c2fb95e048e7919832f72a1cd Mon Sep 17 00:00:00 2001 From: Serguei Katkov Date: Thu, 20 Oct 2022 12:05:33 +0700 Subject: [Inline Spiller] Extend the snippet by statepoint uses Snippet is a tiny live interval which has copy or fill like def and copy or spill like use at the end (any of them might abcent). Snippet has only one use/def inside interval and interval is located in one basic block. When inline spiller spills some reg around uses it also forces the spilling of connected snippets those which got by splitting the same original reg and its def is a full copy of our reg or its last use is a full copy to our reg. The definition of snippet is extended to allow not only one use/def but more. However all other uses are statepoint instructions which will fold fill into its operand. That way we do not introduce new fills/spills. Reviewed By: qcolombet, dantrushin Differential Revision: https://reviews.llvm.org/D138093 --- llvm/lib/CodeGen/StackMaps.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'llvm/lib/CodeGen/StackMaps.cpp') diff --git a/llvm/lib/CodeGen/StackMaps.cpp b/llvm/lib/CodeGen/StackMaps.cpp index f9391d5..e5d8d772 100644 --- a/llvm/lib/CodeGen/StackMaps.cpp +++ b/llvm/lib/CodeGen/StackMaps.cpp @@ -146,6 +146,23 @@ unsigned StatepointOpers::getGCPointerMap( return GCMapSize; } +bool StatepointOpers::isFoldableReg(Register Reg) const { + unsigned FoldableAreaStart = getVarIdx(); + for (const MachineOperand &MO : MI->uses()) { + if (MI->getOperandNo(&MO) >= FoldableAreaStart) + break; + if (MO.isReg() && MO.getReg() == Reg) + return false; + } + return true; +} + +bool StatepointOpers::isFoldableReg(const MachineInstr *MI, Register Reg) { + if (MI->getOpcode() != TargetOpcode::STATEPOINT) + return false; + return StatepointOpers(MI).isFoldableReg(Reg); +} + StackMaps::StackMaps(AsmPrinter &AP) : AP(AP) { if (StackMapVersion != 3) llvm_unreachable("Unsupported stackmap version!"); -- cgit v1.1