Skip to content

Commit

Permalink
[MC] Make .pseudo_probe sections deterministic after D91878
Browse files Browse the repository at this point in the history
MCPseudoProbeSections::emit iterates over MCProbeDivisions and creates sections.
When the map key is MCSymbol *, the iteration order is not stable. The
underlying BumpPtrAllocator largely decreases the flakiness. That said,
the allocations from BumpPtrAllocator may have different orders.
Under tcmalloc, llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll fails
about 7 times per 1000 runs.
  • Loading branch information
MaskRay committed Sep 20, 2023
1 parent 933ad5c commit c8fd0cf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions llvm/include/llvm/MC/MCPseudoProbe.h
Expand Up @@ -55,6 +55,7 @@
#define LLVM_MC_MCPSEUDOPROBE_H

#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/PseudoProbe.h"
Expand Down Expand Up @@ -299,8 +300,7 @@ class MCPseudoProbeSections {
MCProbeDivisions[FuncSym].addPseudoProbe(Probe, InlineStack);
}

// TODO: Sort by getOrdinal to ensure a determinstic section order
using MCProbeDivisionMap = std::map<MCSymbol *, MCPseudoProbeInlineTree>;
using MCProbeDivisionMap = MapVector<MCSymbol *, MCPseudoProbeInlineTree>;

private:
// A collection of MCPseudoProbe for each function. The MCPseudoProbes are
Expand Down

1 comment on commit c8fd0cf

@kda
Copy link
Contributor

@kda kda commented on c8fd0cf Sep 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.