[RFC] Profile Information Propagation Unittesting

We now have the support for the first phase in this RFC (see also Issue #147390 tracking the more interesting changes). The buildbot is coming shortly, but I wanted to update on some results and also ask for help.

How to repro:

cmake -GNinja ../llvm \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=On \
-DCMAKE_EXPORT_COMPILE_COMMANDS=On \
-DLLVM_ENABLE_LLD=On \
-DLLVM_LIT_ARGS="--exclude-xfail" \
-DLLVM_ENABLE_PROFCHECK=On

ninja check-llvm

TL;DR; this makes opt inject MD_prof metadata before running the rest of a test, and then checks that terminators with more than 1 successor still have MD_prof at the end - doesn’t check the metadata is valid, just that it’s present (as explained in the RFC).

I grouped failures up to depth of 2 in the test name, and counted them. Some are probably false positives, e.g. I think the Instrumentation ones could be excluded; the Transforms ones, perhaps less so.

My plan is to go through the Transforms ones initially and address them - there probably is (hopefully) a much smaller set of underlying issues than the counts. But I would appreciate any community help if folks are interested in addressing specific areas (in Transforms), please let me know so we don’t duplicate effort. If so, could you please reply to this thread, ideally by EOW? Thanks!

What would be involved for a pass that drops metadata: modify it to synthesize MD_prof correctly, or, if the correct branch metadata cannot possibly be computed from the existing profile, specify that it’s unknown with setExplicitlyUnknownBranchWeights.

      1 Analysis/LoopAccessAnalysis
      3 Analysis/MemorySSA
      1 Analysis/StackSafetyAnalysis
      1 Bitcode/fcmp-fast.ll
      1 Bitcode/flags.ll
      5 CodeGen/AArch64
     51 CodeGen/AMDGPU
      1 CodeGen/ARM
      4 CodeGen/Hexagon
      1 CodeGen/NVPTX
      1 CodeGen/PowerPC
      3 CodeGen/X86
      2 DebugInfo/AArch64
      1 DebugInfo/assignment-tracking
      1 DebugInfo/debugify-each.ll
      1 DebugInfo/Generic
      1 DebugInfo/KeyInstructions
      1 DebugInfo/X86
    118 Instrumentation/AddressSanitizer
      6 Instrumentation/BoundsChecking
     11 Instrumentation/DataFlowSanitizer
     12 Instrumentation/HeapProfiler
     53 Instrumentation/HWAddressSanitizer
      9 Instrumentation/InstrProfiling
      3 Instrumentation/JustMyCode
    140 Instrumentation/MemorySanitizer
      6 Instrumentation/NumericalStabilitySanitizer
      3 Instrumentation/RealtimeSanitizer
      4 Instrumentation/SanitizerBinaryMetadata
     31 Instrumentation/SanitizerCoverage
      1 Instrumentation/sanitizers-naked.ll
      3 Instrumentation/ThreadSanitizer
     13 Instrumentation/TypeSanitizer
      1 Other/ChangePrinters
      1 Other/opt-bisect-print-ir-path.ll
      1 Other/printer.ll
      1 Other/X86
      1 tools/not
     21 tools/UpdateTestChecks
      4 Transforms/AggressiveInstCombine
     45 Transforms/AtomicExpand
     50 Transforms/Attributor
      2 Transforms/BlockExtractor
     11 Transforms/CodeExtractor
      7 Transforms/CodeGenPrepare
     31 Transforms/Coroutines
      3 Transforms/CrossDSOCFI
      5 Transforms/DFAJumpThreading
      5 Transforms/ExpandLargeDivRem
      4 Transforms/ExpandLargeFpConvert
      3 Transforms/ExpandMemCmp
      3 Transforms/ExpandVariadics
      4 Transforms/FixIrreducible
      1 Transforms/FunctionSpecialization
     15 Transforms/GCOVProfiling
     39 Transforms/HotColdSplit
      1 Transforms/IndirectBrExpand
      1 Transforms/Inline
      2 Transforms/InstCombine
     32 Transforms/IRCE
     83 Transforms/IROutliner
      4 Transforms/JumpTableToSwitch
      6 Transforms/JumpThreading
      3 Transforms/LICM
      3 Transforms/LoopBoundSplit
     11 Transforms/LoopDistribute
      3 Transforms/LoopFlatten
      8 Transforms/LoopIdiom
      7 Transforms/LoopLoadElim
      1 Transforms/LoopPredication
      9 Transforms/LoopSimplifyCFG
      3 Transforms/LoopUnroll
    274 Transforms/LoopVectorize
     14 Transforms/LoopVersioning
      4 Transforms/LoopVersioningLICM
      3 Transforms/LowerGlobalDestructors
      4 Transforms/LowerIFunc
      5 Transforms/LowerMatrixIntrinsics
     12 Transforms/LowerSwitch
     27 Transforms/LowerTypeTests
     37 Transforms/MergeFunc
      4 Transforms/MergeICmps
     14 Transforms/OpenMP
      1 Transforms/PartiallyInlineLibCalls
      5 Transforms/PGOProfile
      7 Transforms/PhaseOrdering
      6 Transforms/PreISelIntrinsicLowering
      3 Transforms/SampleProfile
     13 Transforms/ScalarizeMaskedMemIntrin
     22 Transforms/SimpleLoopUnswitch
     20 Transforms/SimplifyCFG
      1 Transforms/SLPVectorizer
      6 Transforms/SROA
      1 Transforms/StackProtector
      7 Transforms/StructurizeCFG
      6 Transforms/UnifyLoopExits
      1 Transforms/Util
     11 Transforms/WholeProgramDevirt
1 Like