From 2a24d350dbeacb131af91e8c438fed2bd81698c0 Mon Sep 17 00:00:00 2001 From: Chen Zheng Date: Tue, 26 May 2020 22:39:37 -0400 Subject: [PATCH] [MachineCombine] add a hook for resource length limit --- llvm/include/llvm/CodeGen/TargetInstrInfo.h | 3 +++ llvm/lib/CodeGen/MachineCombiner.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/llvm/include/llvm/CodeGen/TargetInstrInfo.h b/llvm/include/llvm/CodeGen/TargetInstrInfo.h index 8c6d845..709030b 100644 --- a/llvm/include/llvm/CodeGen/TargetInstrInfo.h +++ b/llvm/include/llvm/CodeGen/TargetInstrInfo.h @@ -1093,6 +1093,9 @@ public: SmallVectorImpl &DelInstrs, DenseMap &InstrIdxForVirtReg) const; + /// The limit on resource length extension we accept in MachineCombiner Pass. + virtual int getExtendResourceLenLimit() const { return 0; } + /// This is an architecture-specific helper function of reassociateOps. /// Set special operand attributes for new instructions after reassociation. virtual void setSpecialOperandAttr(MachineInstr &OldMI1, MachineInstr &OldMI2, diff --git a/llvm/lib/CodeGen/MachineCombiner.cpp b/llvm/lib/CodeGen/MachineCombiner.cpp index 73895bd..34087d0 100644 --- a/llvm/lib/CodeGen/MachineCombiner.cpp +++ b/llvm/lib/CodeGen/MachineCombiner.cpp @@ -406,12 +406,14 @@ bool MachineCombiner::preservesResourceLen( << ResLenBeforeCombine << " and after: " << ResLenAfterCombine << "\n";); LLVM_DEBUG( - ResLenAfterCombine <= ResLenBeforeCombine + ResLenAfterCombine <= + ResLenBeforeCombine + TII->getExtendResourceLenLimit() ? dbgs() << "\t\t As result it IMPROVES/PRESERVES Resource Length\n" : dbgs() << "\t\t As result it DOES NOT improve/preserve Resource " "Length\n"); - return ResLenAfterCombine <= ResLenBeforeCombine; + return ResLenAfterCombine <= + ResLenBeforeCombine + TII->getExtendResourceLenLimit(); } /// \returns true when new instruction sequence should be generated -- 2.7.4