[clang] [llvm] [NFC] Replace more DenseMaps with SmallDenseMaps (PR #111836)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 10 06:33:19 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 774893dcd929c370bad714a70a7d670bb2d6f649 d2b935e3a537e065b00f543a1792d1979ba413d9 --extensions h,cpp -- clang/include/clang/AST/CXXInheritance.h clang/lib/AST/ItaniumMangle.cpp llvm/include/llvm/ADT/SCCIterator.h llvm/include/llvm/Analysis/ConstraintSystem.h llvm/include/llvm/Analysis/DominanceFrontier.h llvm/include/llvm/Analysis/DominanceFrontierImpl.h llvm/include/llvm/Analysis/LoopIterator.h llvm/include/llvm/Analysis/MemorySSA.h llvm/include/llvm/Analysis/MustExecute.h llvm/include/llvm/IR/EHPersonalities.h llvm/include/llvm/IR/PredIteratorCache.h llvm/include/llvm/Transforms/Utils/Cloning.h llvm/include/llvm/Transforms/Utils/SSAUpdaterImpl.h llvm/lib/Analysis/InlineCost.cpp llvm/lib/Analysis/LazyValueInfo.cpp llvm/lib/Analysis/MustExecute.cpp llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp llvm/lib/CodeGen/MachineSSAUpdater.cpp llvm/lib/CodeGen/WinEHPrepare.cpp llvm/lib/IR/EHPersonalities.cpp llvm/lib/IR/Verifier.cpp llvm/lib/Target/X86/X86WinEHState.cpp llvm/lib/Transforms/InstCombine/InstructionCombining.cpp llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp llvm/lib/Transforms/ObjCARC/ObjCARC.cpp llvm/lib/Transforms/ObjCARC/ObjCARC.h llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp llvm/lib/Transforms/Scalar/ConstraintElimination.cpp llvm/lib/Transforms/Scalar/Reassociate.cpp llvm/lib/Transforms/Utils/SSAUpdater.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/include/llvm/Analysis/LoopIterator.h b/llvm/include/llvm/Analysis/LoopIterator.h
index aaca0298d2..b641cd5231 100644
--- a/llvm/include/llvm/Analysis/LoopIterator.h
+++ b/llvm/include/llvm/Analysis/LoopIterator.h
@@ -97,8 +97,8 @@ struct LoopBodyTraits {
 class LoopBlocksDFS {
 public:
   /// Postorder list iterators.
-  typedef SmallVector<BasicBlock*, 16>::const_iterator POIterator;
-  typedef SmallVector<BasicBlock*, 16>::const_reverse_iterator RPOIterator;
+  typedef SmallVector<BasicBlock *, 16>::const_iterator POIterator;
+  typedef SmallVector<BasicBlock *, 16>::const_reverse_iterator RPOIterator;
 
   friend class LoopBlocksTraversal;
 
@@ -108,8 +108,8 @@ private:
   /// Map each block to its postorder number. A block is only mapped after it is
   /// preorder visited by DFS. It's postorder number is initially zero and set
   /// to nonzero after it is finished by postorder traversal.
-  SmallDenseMap<BasicBlock*, unsigned, 16> PostNumbers;
-  SmallVector<BasicBlock*, 16> PostBlocks;
+  SmallDenseMap<BasicBlock *, unsigned, 16> PostNumbers;
+  SmallVector<BasicBlock *, 16> PostBlocks;
 
 public:
   LoopBlocksDFS(Loop *Container) :
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index d7e663d60d..81899e9fe1 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -322,7 +322,7 @@ class LazyValueInfoImpl {
   SmallVector<std::pair<BasicBlock*, Value*>, 8> BlockValueStack;
 
   /// Keeps track of which block-value pairs are in BlockValueStack.
-  SmallDenseSet<std::pair<BasicBlock*, Value*>, 16> BlockValueSet;
+  SmallDenseSet<std::pair<BasicBlock *, Value *>, 16> BlockValueSet;
 
   /// Push BV onto BlockValueStack unless it's already in there.
   /// Returns true on success.
diff --git a/llvm/lib/Analysis/MustExecute.cpp b/llvm/lib/Analysis/MustExecute.cpp
index 52d631b56b..d08165633c 100644
--- a/llvm/lib/Analysis/MustExecute.cpp
+++ b/llvm/lib/Analysis/MustExecute.cpp
@@ -28,8 +28,7 @@ using namespace llvm;
 
 #define DEBUG_TYPE "must-execute"
 
-const BlockColorMapT &
-LoopSafetyInfo::getBlockColors() const {
+const BlockColorMapT &LoopSafetyInfo::getBlockColors() const {
   return BlockColors;
 }
 
diff --git a/llvm/lib/Target/X86/X86WinEHState.cpp b/llvm/lib/Target/X86/X86WinEHState.cpp
index 199f8438c6..2181d7a70d 100644
--- a/llvm/lib/Target/X86/X86WinEHState.cpp
+++ b/llvm/lib/Target/X86/X86WinEHState.cpp
@@ -70,10 +70,10 @@ private:
   bool isStateStoreNeeded(EHPersonality Personality, CallBase &Call);
   void rewriteSetJmpCall(IRBuilder<> &Builder, Function &F, CallBase &Call,
                          Value *State);
-  int getBaseStateForBB(BlockColorMapT &BlockColors,
-                        WinEHFuncInfo &FuncInfo, BasicBlock *BB);
-  int getStateForCall(BlockColorMapT &BlockColors,
-                      WinEHFuncInfo &FuncInfo, CallBase &Call);
+  int getBaseStateForBB(BlockColorMapT &BlockColors, WinEHFuncInfo &FuncInfo,
+                        BasicBlock *BB);
+  int getStateForCall(BlockColorMapT &BlockColors, WinEHFuncInfo &FuncInfo,
+                      CallBase &Call);
 
   // Module-level type getters.
   Type *getEHLinkRegistrationType();
@@ -500,9 +500,8 @@ void WinEHStatePass::rewriteSetJmpCall(IRBuilder<> &Builder, Function &F,
 }
 
 // Figure out what state we should assign calls in this block.
-int WinEHStatePass::getBaseStateForBB(
-    BlockColorMapT &BlockColors, WinEHFuncInfo &FuncInfo,
-    BasicBlock *BB) {
+int WinEHStatePass::getBaseStateForBB(BlockColorMapT &BlockColors,
+                                      WinEHFuncInfo &FuncInfo, BasicBlock *BB) {
   int BaseState = ParentBaseState;
   auto &BBColors = BlockColors[BB];
 
@@ -519,9 +518,8 @@ int WinEHStatePass::getBaseStateForBB(
 }
 
 // Calculate the state a call-site is in.
-int WinEHStatePass::getStateForCall(
-    BlockColorMapT &BlockColors, WinEHFuncInfo &FuncInfo,
-    CallBase &Call) {
+int WinEHStatePass::getStateForCall(BlockColorMapT &BlockColors,
+                                    WinEHFuncInfo &FuncInfo, CallBase &Call) {
   if (auto *II = dyn_cast<InvokeInst>(&Call)) {
     // Look up the state number of the EH pad this unwinds to.
     assert(FuncInfo.InvokeStateMap.count(II) && "invoke has no state!");
diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
index 164ffbec26..8ca2663bb5 100644
--- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
+++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
@@ -863,8 +863,7 @@ BasicBlock *FuncPGOInstrumentation<Edge, BBInfo>::getInstrBB(Edge *E) {
 // funclet information, if any is needed, that should be placed on the generated
 // value profiling call for the value profile candidate call.
 static void
-populateEHOperandBundle(VPCandidateInfo &Cand,
-                        BlockColorMapT &BlockColors,
+populateEHOperandBundle(VPCandidateInfo &Cand, BlockColorMapT &BlockColors,
                         SmallVectorImpl<OperandBundleDef> &OpBundles) {
   auto *OrigCall = dyn_cast<CallBase>(Cand.AnnotatedInst);
   if (!OrigCall)
diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARC.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARC.cpp
index 4745bb9bbc..86149e820f 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARC.cpp
+++ b/llvm/lib/Transforms/ObjCARC/ObjCARC.cpp
@@ -21,10 +21,11 @@
 using namespace llvm;
 using namespace llvm::objcarc;
 
-CallInst *objcarc::createCallInstWithColors(
-    FunctionCallee Func, ArrayRef<Value *> Args, const Twine &NameStr,
-    BasicBlock::iterator InsertBefore,
-    const BlockColorMapT &BlockColors) {
+CallInst *objcarc::createCallInstWithColors(FunctionCallee Func,
+                                            ArrayRef<Value *> Args,
+                                            const Twine &NameStr,
+                                            BasicBlock::iterator InsertBefore,
+                                            const BlockColorMapT &BlockColors) {
   FunctionType *FTy = Func.getFunctionType();
   Value *Callee = Func.getCallee();
   SmallVector<OperandBundleDef, 1> OpBundles;
diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARC.h b/llvm/lib/Transforms/ObjCARC/ObjCARC.h
index fe08aec6d4..ebddff65cc 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARC.h
+++ b/llvm/lib/Transforms/ObjCARC/ObjCARC.h
@@ -97,10 +97,10 @@ static inline MDString *getRVInstMarker(Module &M) {
 /// Create a call instruction with the correct funclet token. This should be
 /// called instead of calling CallInst::Create directly unless the call is
 /// going to be removed from the IR before WinEHPrepare.
-CallInst *createCallInstWithColors(
-    FunctionCallee Func, ArrayRef<Value *> Args, const Twine &NameStr,
-    BasicBlock::iterator InsertBefore,
-    const BlockColorMapT &BlockColors);
+CallInst *createCallInstWithColors(FunctionCallee Func, ArrayRef<Value *> Args,
+                                   const Twine &NameStr,
+                                   BasicBlock::iterator InsertBefore,
+                                   const BlockColorMapT &BlockColors);
 
 class BundledRetainClaimRVs {
 public:
@@ -117,9 +117,9 @@ public:
                          CallBase *AnnotatedCall);
 
   /// Insert a retainRV/claimRV call with colors.
-  CallInst *insertRVCallWithColors(
-      BasicBlock::iterator InsertPt, CallBase *AnnotatedCall,
-      const BlockColorMapT &BlockColors);
+  CallInst *insertRVCallWithColors(BasicBlock::iterator InsertPt,
+                                   CallBase *AnnotatedCall,
+                                   const BlockColorMapT &BlockColors);
 
   /// See if an instruction is a bundled retainRV/claimRV call.
   bool contains(const Instruction *I) const {
diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
index 60ba0a8752..513361b41b 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
+++ b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
@@ -85,19 +85,18 @@ class ObjCARCContract {
   SmallPtrSet<CallInst *, 8> StoreStrongCalls;
 
   /// Returns true if we eliminated Inst.
-  bool tryToPeepholeInstruction(
-      Function &F, Instruction *Inst, inst_iterator &Iter,
-      bool &TailOkForStoreStrong,
-      const BlockColorMapT &BlockColors);
+  bool tryToPeepholeInstruction(Function &F, Instruction *Inst,
+                                inst_iterator &Iter, bool &TailOkForStoreStrong,
+                                const BlockColorMapT &BlockColors);
 
   bool optimizeRetainCall(Function &F, Instruction *Retain);
 
   bool contractAutorelease(Function &F, Instruction *Autorelease,
                            ARCInstKind Class);
 
-  void tryToContractReleaseIntoStoreStrong(
-      Instruction *Release, inst_iterator &Iter,
-      const BlockColorMapT &BlockColors);
+  void tryToContractReleaseIntoStoreStrong(Instruction *Release,
+                                           inst_iterator &Iter,
+                                           const BlockColorMapT &BlockColors);
 
 public:
   bool init(Module &M);
@@ -414,8 +413,7 @@ void ObjCARCContract::tryToContractReleaseIntoStoreStrong(
 
 bool ObjCARCContract::tryToPeepholeInstruction(
     Function &F, Instruction *Inst, inst_iterator &Iter,
-    bool &TailOkForStoreStrongs,
-    const BlockColorMapT &BlockColors) {
+    bool &TailOkForStoreStrongs, const BlockColorMapT &BlockColors) {
   // Only these library routines return their argument. In particular,
   // objc_retainBlock does not necessarily return its argument.
   ARCInstKind Class = GetBasicARCInstKind(Inst);
diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
index 452750ba5a..71e397f873 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -288,7 +288,8 @@ public:
   SmallDenseMap<Value *, unsigned, 16> &getValue2Index(bool Signed) {
     return Signed ? SignedCS.getValue2Index() : UnsignedCS.getValue2Index();
   }
-  const SmallDenseMap<Value *, unsigned, 16> &getValue2Index(bool Signed) const {
+  const SmallDenseMap<Value *, unsigned, 16> &
+  getValue2Index(bool Signed) const {
     return Signed ? SignedCS.getValue2Index() : UnsignedCS.getValue2Index();
   }
 
@@ -892,8 +893,9 @@ void ConstraintInfo::transferToOtherSystem(
 
 #ifndef NDEBUG
 
-static void dumpConstraint(ArrayRef<int64_t> C,
-                           const SmallDenseMap<Value *, unsigned, 16> &Value2Index) {
+static void
+dumpConstraint(ArrayRef<int64_t> C,
+               const SmallDenseMap<Value *, unsigned, 16> &Value2Index) {
   ConstraintSystem CS(Value2Index);
   CS.addVariableRowFill(C);
   CS.dump();

``````````

</details>


https://github.com/llvm/llvm-project/pull/111836


More information about the cfe-commits mailing list