Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

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.

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.
@llvmbot
Copy link
Member

llvmbot commented May 21, 2025

@llvm/pr-subscribers-function-specialization

Author: Kazu Hirata (kazutakahirata)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/140851.diff

2 Files Affected:

  • (modified) llvm/include/llvm/Transforms/Utils/SCCPSolver.h (+1-1)
  • (modified) llvm/lib/Transforms/Utils/SCCPSolver.cpp (+2-2)
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();
 }
 

@llvmbot
Copy link
Member

llvmbot commented May 21, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Kazu Hirata (kazutakahirata)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/140851.diff

2 Files Affected:

  • (modified) llvm/include/llvm/Transforms/Utils/SCCPSolver.h (+1-1)
  • (modified) llvm/lib/Transforms/Utils/SCCPSolver.cpp (+2-2)
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();
 }
 

Copy link
Contributor

@fhahn fhahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. thanks

@kazutakahirata kazutakahirata merged commit 5a3776a into llvm:main May 21, 2025
14 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_drop_const_clang_StaticAnalyzer branch May 21, 2025 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants