[llvm] [ReachingDefAnalysis] Fix management of MBBFrameObjsReachingDefs (PR #124943)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 31 10:18:54 PST 2025


================
@@ -147,16 +147,9 @@ void ReachingDefAnalysis::processDefs(MachineInstr *MI) {
       assert(FrameIndex >= 0 && "Can't handle negative frame indicies yet!");
       if (!isFIDef(*MI, FrameIndex, TII))
         continue;
-      if (MBBFrameObjsReachingDefs.contains(MBBNumber)) {
-        auto Frame2InstrIdx = MBBFrameObjsReachingDefs[MBBNumber];
-        if (Frame2InstrIdx.count(FrameIndex - ObjectIndexBegin) > 0)
-          Frame2InstrIdx[FrameIndex - ObjectIndexBegin].push_back(CurInstr);
-        else
-          Frame2InstrIdx[FrameIndex - ObjectIndexBegin] = {CurInstr};
-      } else {
-        MBBFrameObjsReachingDefs[MBBNumber] = {
-            {FrameIndex - ObjectIndexBegin, {CurInstr}}};
-      }
+
+      int Key = FrameIndex - ObjectIndexBegin;
+      MBBFrameObjsReachingDefs[MBBNumber][Key].push_back(CurInstr);
----------------
topperc wrote:

A map of maps is a kind of silly data structure. You can make the key a std::pair and use a single level map. Unless we need to be able to easily access the inner map for a single basic block.

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


More information about the llvm-commits mailing list