[llvm] [CodeGen][NFC] Replace std::function with llvm::function_ref (PR #228431)

Tim Gymnich via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 06:14:17 PDT 2026


https://github.com/tgymnich updated https://github.com/llvm/llvm-project/pull/228431

>From 1c883dc6c8e60ae1f1e52cfdbc18206382b9a812 Mon Sep 17 00:00:00 2001
From: Tim Gymnich <tim at gymni.ch>
Date: Fri, 2 Oct 2026 14:34:13 +0200
Subject: [PATCH] replace std::function with llvm::function_ref

---
 llvm/include/llvm/CodeGen/GlobalISel/Utils.h | 2 +-
 llvm/lib/CodeGen/GlobalISel/Utils.cpp        | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/GlobalISel/Utils.h b/llvm/include/llvm/CodeGen/GlobalISel/Utils.h
index 7b339211cc3ca38..30af31e103e6b8f 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/Utils.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/Utils.h
@@ -563,7 +563,7 @@ isConstantOrConstantSplatVectorFP(Register Def, const MachineRegisterInfo &MRI);
 /// value was undef.
 LLVM_ABI bool
 matchUnaryPredicate(const MachineRegisterInfo &MRI, Register Reg,
-                    std::function<bool(const Constant *ConstVal)> Match,
+                    llvm::function_ref<bool(const Constant *ConstVal)> Match,
                     bool AllowUndefs = false);
 
 /// Returns true if given the TargetLowering's boolean contents information,
diff --git a/llvm/lib/CodeGen/GlobalISel/Utils.cpp b/llvm/lib/CodeGen/GlobalISel/Utils.cpp
index d0cc4a823d7f5fb..9a369bbdced1ad9 100644
--- a/llvm/lib/CodeGen/GlobalISel/Utils.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/Utils.cpp
@@ -1571,7 +1571,8 @@ bool llvm::isAllOnesOrAllOnesSplat(const MachineInstr &MI,
 
 bool llvm::matchUnaryPredicate(
     const MachineRegisterInfo &MRI, Register Reg,
-    std::function<bool(const Constant *ConstVal)> Match, bool AllowUndefs) {
+    llvm::function_ref<bool(const Constant *ConstVal)> Match,
+    bool AllowUndefs) {
 
   const MachineInstr *Def = getDefIgnoringCopies(Reg, MRI);
   if (AllowUndefs && Def->getOpcode() == TargetOpcode::G_IMPLICIT_DEF)



More information about the llvm-commits mailing list