[llvm] af9a452 - [llvm][codegen] Fix non-determinism in StackFrameLayoutAnalysisPass output
Paul Kirth via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 19 12:04:22 PST 2023
Author: Paul Kirth
Date: 2023-01-19T20:04:14Z
New Revision: af9a452e57554c2c5e876986e33c2a75314259e8
URL: https://github.com/llvm/llvm-project/commit/af9a452e57554c2c5e876986e33c2a75314259e8
DIFF: https://github.com/llvm/llvm-project/commit/af9a452e57554c2c5e876986e33c2a75314259e8.diff
LOG: [llvm][codegen] Fix non-determinism in StackFrameLayoutAnalysisPass output
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.
Also remove the "Stack Frame Layout" lines from arm64-opt-remarks-lazy-bfi test,
since those also break under reverse iteration.
Reviewed By: nickdesaulniers
Differential Revision: https://reviews.llvm.org/D142127
Added:
Modified:
llvm/lib/CodeGen/StackFrameLayoutAnalysisPass.cpp
llvm/test/CodeGen/AArch64/arm64-opt-remarks-lazy-bfi.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/StackFrameLayoutAnalysisPass.cpp b/llvm/lib/CodeGen/StackFrameLayoutAnalysisPass.cpp
index ddac093423fa6..3a48dd5b0a034 100644
--- a/llvm/lib/CodeGen/StackFrameLayoutAnalysisPass.cpp
+++ b/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 @@ namespace {
/// 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 @@ struct StackFrameLayoutAnalysisPass : public MachineFunctionPass {
<< 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
diff --git a/llvm/test/CodeGen/AArch64/arm64-opt-remarks-lazy-bfi.ll b/llvm/test/CodeGen/AArch64/arm64-opt-remarks-lazy-bfi.ll
index 9295897dd22d3..2b826b208f551 100644
--- a/llvm/test/CodeGen/AArch64/arm64-opt-remarks-lazy-bfi.ll
+++ b/llvm/test/CodeGen/AArch64/arm64-opt-remarks-lazy-bfi.ll
@@ -38,13 +38,7 @@
; HOTNESS-NEXT: Freeing Pass 'Insert CFI remember/restore state instructions' on Function 'empty_func'
; HOTNESS-NEXT: Executing Pass 'Verify generated machine code'
; HOTNESS-NEXT: Freeing Pass 'Verify generated machine code'
-; HOTNESS-NEXT: Executing Pass 'Lazy Machine Block Frequency Analysis'
-; HOTNESS-NEXT: Executing Pass 'Machine Optimization Remark Emitter'
-; HOTNESS: Executing Pass 'Stack Frame Layout Analysis'
-; HOTNESS-NEXT: Freeing Pass 'Machine Optimization Remark Emitter'
-; HOTNESS-NEXT: Freeing Pass 'Lazy Machine Block Frequency Analysis'
-; HOTNESS-NEXT: Freeing Pass 'Stack Frame Layout Analysis'
-; HOTNESS-NEXT: Executing Pass 'Unpack machine instruction bundles'
+; HOTNESS: Executing Pass 'Unpack machine instruction bundles'
; HOTNESS-NEXT: Freeing Pass 'Unpack machine instruction bundles'
; HOTNESS-NEXT: Executing Pass 'Verify generated machine code'
; HOTNESS-NEXT: Freeing Pass 'Verify generated machine code'
@@ -69,13 +63,7 @@
; NO_HOTNESS-NEXT: Freeing Pass 'Insert CFI remember/restore state instructions' on Function 'empty_func'
; NO_HOTNESS-NEXT: Executing Pass 'Verify generated machine code'
; NO_HOTNESS-NEXT: Freeing Pass 'Verify generated machine code'
-; NO_HOTNESS-NEXT: Executing Pass 'Lazy Machine Block Frequency Analysis'
-; NO_HOTNESS-NEXT: Executing Pass 'Machine Optimization Remark Emitter'
-; NO_HOTNESS: Executing Pass 'Stack Frame Layout Analysis'
-; NO_HOTNESS-NEXT: Freeing Pass 'Machine Optimization Remark Emitter'
-; NO_HOTNESS-NEXT: Freeing Pass 'Lazy Machine Block Frequency Analysis'
-; NO_HOTNESS-NEXT: Freeing Pass 'Stack Frame Layout Analysis'
-; NO_HOTNESS-NEXT: Executing Pass 'Unpack machine instruction bundles'
+; NO_HOTNESS: Executing Pass 'Unpack machine instruction bundles'
; NO_HOTNESS-NEXT: Freeing Pass 'Unpack machine instruction bundles'
; NO_HOTNESS-NEXT: Executing Pass 'Verify generated machine code'
; NO_HOTNESS-NEXT: Freeing Pass 'Verify generated machine code'
More information about the llvm-commits
mailing list