[llvm] 929a8c9 - [FuncSpec][NFC] Rename cryptic variable to better describe it.

Alexandros Lamprineas via llvm-commits llvm-commits at lists.llvm.org
Tue May 9 04:01:37 PDT 2023


Author: Alexandros Lamprineas
Date: 2023-05-09T11:55:40+01:00
New Revision: 929a8c9f72dc405779a8aaf82304efdb7f1ab5e4

URL: https://github.com/llvm/llvm-project/commit/929a8c9f72dc405779a8aaf82304efdb7f1ab5e4
DIFF: https://github.com/llvm/llvm-project/commit/929a8c9f72dc405779a8aaf82304efdb7f1ab5e4.diff

LOG: [FuncSpec][NFC] Rename cryptic variable to better describe it.

UM -> UniqueSpecs

Brought up on the review of D145379. Committing it seperately for now
since the Cost model improvements need rethink.

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/FunctionSpecialization.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp b/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
index 7d082983b9d7..51f1319a6812 100644
--- a/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
@@ -440,7 +440,7 @@ bool FunctionSpecializer::findSpecializations(Function *F, Cost SpecCost,
   // A mapping from a specialisation signature to the index of the respective
   // entry in the all specialisation array. Used to ensure uniqueness of
   // specialisations.
-  DenseMap<SpecSig, unsigned> UM;
+  DenseMap<SpecSig, unsigned> UniqueSpecs;
 
   // Get a list of interesting arguments.
   SmallVector<Argument *> Args;
@@ -451,7 +451,6 @@ bool FunctionSpecializer::findSpecializations(Function *F, Cost SpecCost,
   if (Args.empty())
     return false;
 
-  bool Found = false;
   for (User *U : F->users()) {
     if (!isa<CallInst>(U) && !isa<InvokeInst>(U))
       continue;
@@ -488,7 +487,7 @@ bool FunctionSpecializer::findSpecializations(Function *F, Cost SpecCost,
       continue;
 
     // Check if we have encountered the same specialisation already.
-    if (auto It = UM.find(S); It != UM.end()) {
+    if (auto It = UniqueSpecs.find(S); It != UniqueSpecs.end()) {
       // Existing specialisation. Add the call to the list to rewrite, unless
       // it's a recursive call. A specialisation, generated because of a
       // recursive call may end up as not the best specialisation for all
@@ -515,14 +514,13 @@ bool FunctionSpecializer::findSpecializations(Function *F, Cost SpecCost,
       if (CS.getFunction() != F)
         Spec.CallSites.push_back(&CS);
       const unsigned Index = AllSpecs.size() - 1;
-      UM[S] = Index;
+      UniqueSpecs[S] = Index;
       if (auto [It, Inserted] = SM.try_emplace(F, Index, Index + 1); !Inserted)
         It->second.second = Index + 1;
-      Found = true;
     }
   }
 
-  return Found;
+  return !UniqueSpecs.empty();
 }
 
 bool FunctionSpecializer::isCandidateFunction(Function *F) {


        


More information about the llvm-commits mailing list