[llvm] [SCCPSolver] Make getMRVFunctionsTracked return a reference (NFC) (PR #140851)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue May 20 23:06:12 PDT 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/140851

This patch makes getMRVFunctionsTracked return a reference.
runIPSCCP, the sole user of getMRVFunctionsTracked, just needs a
read-access to the map.

The missing "&" is most likely an oversight as two "sibling" functions
getTrackedRetVals and getTrackedGlobals return maps by const
reference.


>From 77e57e89a15e710152ff6c67b2043f9ab918e7fc Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 20 May 2025 22:45:27 -0700
Subject: [PATCH] [SCCPSolver] Make getMRVFunctionsTracked return a reference
 (NFC)

This patch makes getMRVFunctionsTracked return a reference.
runIPSCCP, the sole user of getMRVFunctionsTracked, just needs a
read-access to the map.

The missing "&" is most likely an oversight as two "sibling" functions
getTrackedRetVals and getTrackedGlobals return maps by const
reference.
---
 llvm/include/llvm/Transforms/Utils/SCCPSolver.h | 2 +-
 llvm/lib/Transforms/Utils/SCCPSolver.cpp        | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/llvm/include/llvm/Transforms/Utils/SCCPSolver.h b/llvm/include/llvm/Transforms/Utils/SCCPSolver.h
index 696f39ca984d1..f8966f5b7472f 100644
--- a/llvm/include/llvm/Transforms/Utils/SCCPSolver.h
+++ b/llvm/include/llvm/Transforms/Utils/SCCPSolver.h
@@ -147,7 +147,7 @@ class SCCPSolver {
 
   /// getMRVFunctionsTracked - Get the set of functions which return multiple
   /// values tracked by the pass.
-  const SmallPtrSet<Function *, 16> getMRVFunctionsTracked();
+  const SmallPtrSet<Function *, 16> &getMRVFunctionsTracked();
 
   /// markOverdefined - Mark the specified value overdefined.  This
   /// works with both scalars and structs.
diff --git a/llvm/lib/Transforms/Utils/SCCPSolver.cpp b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
index c64254140cf22..8a89bf654540c 100644
--- a/llvm/lib/Transforms/Utils/SCCPSolver.cpp
+++ b/llvm/lib/Transforms/Utils/SCCPSolver.cpp
@@ -848,7 +848,7 @@ class SCCPInstVisitor : public InstVisitor<SCCPInstVisitor> {
     return TrackedGlobals;
   }
 
-  const SmallPtrSet<Function *, 16> getMRVFunctionsTracked() {
+  const SmallPtrSet<Function *, 16> &getMRVFunctionsTracked() {
     return MRVFunctionsTracked;
   }
 
@@ -2231,7 +2231,7 @@ SCCPSolver::getTrackedGlobals() {
   return Visitor->getTrackedGlobals();
 }
 
-const SmallPtrSet<Function *, 16> SCCPSolver::getMRVFunctionsTracked() {
+const SmallPtrSet<Function *, 16> &SCCPSolver::getMRVFunctionsTracked() {
   return Visitor->getMRVFunctionsTracked();
 }
 



More information about the llvm-commits mailing list