Skip to content

Commit c8fd0cf

Browse files
committed
[MC] Make .pseudo_probe sections deterministic after D91878
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.
1 parent 933ad5c commit c8fd0cf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/include/llvm/MC/MCPseudoProbe.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#define LLVM_MC_MCPSEUDOPROBE_H
5656

5757
#include "llvm/ADT/DenseSet.h"
58+
#include "llvm/ADT/MapVector.h"
5859
#include "llvm/ADT/SmallVector.h"
5960
#include "llvm/ADT/StringRef.h"
6061
#include "llvm/IR/PseudoProbe.h"
@@ -299,8 +300,7 @@ class MCPseudoProbeSections {
299300
MCProbeDivisions[FuncSym].addPseudoProbe(Probe, InlineStack);
300301
}
301302

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

305305
private:
306306
// A collection of MCPseudoProbe for each function. The MCPseudoProbes are

0 commit comments

Comments
 (0)