[PATCH] D142127: [llvm][codegen] Fix non-determinism in StackFrameLayoutAnalysisPass output

Paul Kirth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 19 09:06:19 PST 2023


paulkirth updated this revision to Diff 490551.
paulkirth added a comment.

Switch to SetVector from SmallVector, since we'd like to ensure these are unique.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142127/new/

https://reviews.llvm.org/D142127

Files:
  llvm/lib/CodeGen/StackFrameLayoutAnalysisPass.cpp


Index: llvm/lib/CodeGen/StackFrameLayoutAnalysisPass.cpp
===================================================================
--- llvm/lib/CodeGen/StackFrameLayoutAnalysisPass.cpp
+++ llvm/lib/CodeGen/StackFrameLayoutAnalysisPass.cpp
@@ -16,6 +16,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "llvm/ADT/SetVector.h"
 #include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
@@ -45,8 +46,7 @@
 /// MachineFunction.
 ///
 struct StackFrameLayoutAnalysisPass : public MachineFunctionPass {
-  using SlotDbgMap =
-      SmallDenseMap<int, SmallPtrSet<const DILocalVariable *, 4>>;
+  using SlotDbgMap = SmallDenseMap<int, SetVector<const DILocalVariable *>>;
   static char ID;
 
   enum SlotType {
@@ -180,18 +180,15 @@
                       << MFI.getStackProtectorIndex() << "\n");
 
     std::vector<SlotData> SlotInfo;
-    SmallDenseMap<int, int> SlotOffsetMap;
 
     const unsigned int NumObj = MFI.getNumObjects();
     SlotInfo.reserve(NumObj);
-    SlotOffsetMap.reserve(NumObj);
     // initialize slot info
     for (int Idx = MFI.getObjectIndexBegin(), EndIdx = MFI.getObjectIndexEnd();
          Idx != EndIdx; ++Idx) {
       if (MFI.isDeadObjectIndex(Idx))
         continue;
-      auto &Inserted = SlotInfo.emplace_back(MFI, ValOffset, Idx);
-      SlotOffsetMap[Inserted.Slot] = Inserted.Offset;
+      SlotInfo.emplace_back(MFI, ValOffset, Idx);
     }
 
     // sort the ordering, to match the actual layout in memory


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142127.490551.patch
Type: text/x-patch
Size: 1576 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230119/eb97dab9/attachment.bin>


More information about the llvm-commits mailing list