[llvm] [SelectionDAG] Avoid repeated hash lookups (NFC) (PR #128999)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 26 21:31:02 PST 2025


================
@@ -343,9 +343,10 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf,
     for (auto &KV : EHInfo.UnwindDestToSrcs) {
       const auto *Dest = cast<const BasicBlock *>(KV.first);
       MachineBasicBlock *DestMBB = getMBB(Dest);
-      UnwindDestToSrcs[DestMBB] = SmallPtrSet<BBOrMBB, 4>();
+      auto &Srcs = UnwindDestToSrcs[DestMBB];
+      Srcs = SmallPtrSet<BBOrMBB, 4>();
----------------
kazutakahirata wrote:

Thank you for bringing this up!  I think `Srcs = SmallPtrSet<BBOrMBB, 4>();` is a no-op in this case.  `Dest` comes from keys of `EHInfo.UnwindDestToSrcs`.  Assuming `cast<...>` evaluates to nonnull in every iteration, `Dest` is unique in every iteration, so the default construction with `operator[]` is enough here.  Let me get rid of `Srcs =  SmallPtrSet<BBOrMBB, 4>();`


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


More information about the llvm-commits mailing list