[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 08:18:47 PST 2023
paulkirth created this revision.
Herald added subscribers: mgrang, hiraditya.
Herald added a project: All.
paulkirth requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
We were iterating over a SmallPtrSet when outputting slot variables.
This is still correct but made the test fail under reverse iteration.
This patch replaces the SmallPtrSet with a SmallVector.
Repository:
rG LLVM Github Monorepo
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
@@ -46,7 +46,7 @@
///
struct StackFrameLayoutAnalysisPass : public MachineFunctionPass {
using SlotDbgMap =
- SmallDenseMap<int, SmallPtrSet<const DILocalVariable *, 4>>;
+ SmallDenseMap<int, SmallVector<const DILocalVariable *, 4>>;
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
@@ -214,7 +211,7 @@
// add variables to the map
for (MachineFunction::VariableDbgInfo &DI : MF.getVariableDbgInfo())
- SlotDebugMap[DI.Slot].insert(DI.Var);
+ SlotDebugMap[DI.Slot].push_back(DI.Var);
// Then add all the spills that have debug data
for (MachineBasicBlock &MBB : MF) {
@@ -231,7 +228,7 @@
MI.collectDebugValues(Dbg);
for (MachineInstr *MI : Dbg)
- SlotDebugMap[FrameIdx].insert(MI->getDebugVariable());
+ SlotDebugMap[FrameIdx].push_back(MI->getDebugVariable());
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142127.490529.patch
Type: text/x-patch
Size: 1849 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230119/3d3c555c/attachment.bin>
More information about the llvm-commits
mailing list