aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineInstr.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2025-04-15 07:23:18 +0200
committerGitHub <noreply@github.com>2025-04-14 22:23:18 -0700
commit2538c607e903a1fe0cfcacd5732235cc8ff3adf7 (patch)
treefc18f75f898e9350e539443d077b0e0c367b6273 /llvm/lib/CodeGen/MachineInstr.cpp
parent01c1c78103d026d0d0007ae7b7d54b36edef1324 (diff)
downloadllvm-2538c607e903a1fe0cfcacd5732235cc8ff3adf7.zip
llvm-2538c607e903a1fe0cfcacd5732235cc8ff3adf7.tar.gz
llvm-2538c607e903a1fe0cfcacd5732235cc8ff3adf7.tar.bz2
[CodeGen] Prune headers and move code out of line for build efficiency, NFC (#135622)
I noticed these destructors taking time with -ftime-trace and moved some of them for minor build efficiency improvements. The main impact of moving destructors out of line is that it avoids requiring container fields containing other types from being complete, i.e. one can have uptr<T> or vector<T> as a field with an incomplete type T, and that means we can reduce transitive includes, as with LegalizerInfo.h. Move expensive getDebugOperandsForReg template out-of-line. The std::function instantiation shows up in time trace even if you don't use the function.
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineInstr.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp
index 2409e60..7e4a32f 100644
--- a/llvm/lib/CodeGen/MachineInstr.cpp
+++ b/llvm/lib/CodeGen/MachineInstr.cpp
@@ -794,6 +794,28 @@ bool MachineInstr::shouldUpdateAdditionalCallInfo() const {
return isCandidateForAdditionalCallInfo();
}
+template <typename Operand, typename Instruction>
+static iterator_range<
+ filter_iterator<Operand *, std::function<bool(Operand &Op)>>>
+getDebugOperandsForRegHelper(Instruction *MI, Register Reg) {
+ std::function<bool(Operand & Op)> OpUsesReg(
+ [Reg](Operand &Op) { return Op.isReg() && Op.getReg() == Reg; });
+ return make_filter_range(MI->debug_operands(), OpUsesReg);
+}
+
+iterator_range<filter_iterator<const MachineOperand *,
+ std::function<bool(const MachineOperand &Op)>>>
+MachineInstr::getDebugOperandsForReg(Register Reg) const {
+ return getDebugOperandsForRegHelper<const MachineOperand, const MachineInstr>(
+ this, Reg);
+}
+
+iterator_range<
+ filter_iterator<MachineOperand *, std::function<bool(MachineOperand &Op)>>>
+MachineInstr::getDebugOperandsForReg(Register Reg) {
+ return getDebugOperandsForRegHelper<MachineOperand, MachineInstr>(this, Reg);
+}
+
unsigned MachineInstr::getNumExplicitOperands() const {
unsigned NumOperands = MCID->getNumOperands();
if (!MCID->isVariadic())