[llvm] c8fd0cf - [MC] Make .pseudo_probe sections deterministic after D91878

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 20 13:47:54 PDT 2023


Author: Fangrui Song
Date: 2023-09-20T13:47:48-07:00
New Revision: c8fd0cf713446ac1f3e9b677ec8500365a98c219

URL: https://github.com/llvm/llvm-project/commit/c8fd0cf713446ac1f3e9b677ec8500365a98c219
DIFF: https://github.com/llvm/llvm-project/commit/c8fd0cf713446ac1f3e9b677ec8500365a98c219.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/include/llvm/MC/MCPseudoProbe.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/MC/MCPseudoProbe.h b/llvm/include/llvm/MC/MCPseudoProbe.h
index 4904cb4ca545676..fb8f4afefa939a3 100644
--- a/llvm/include/llvm/MC/MCPseudoProbe.h
+++ b/llvm/include/llvm/MC/MCPseudoProbe.h
@@ -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"
@@ -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


        


More information about the llvm-commits mailing list