<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/54170>54170</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Catastophic (Hash: 0x0a4d0ad3efffffff) failure in PGO
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Mark-Dunn-OIL
      </td>
    </tr>
</table>

<pre>
    My PGO raw profile data has sufferred catastrophic hash failure.
The Hash: 0x0a4d0ad3efffffff occurs many times

# llvm-profdata show /git/llvm-project/instrumented/profiles/default_487917923513444908_0.profraw --all-functions : 
Counters:
  _Z17GetExecutablePathPKcb:
    Hash: 0x0a84e9f80eae2dac
    Counters: 10
  main:
    Hash: 0x0e5a546d069d6375
    Counters: 205
  /git/llvm-project/clang/tools/driver/driver.cpp:_ZL14ExecuteCC1ToolRN4llvm15SmallVectorImplIPKcEE:
    Hash: 0x07d41591881c618d
    Counters: 13
  /git/llvm-project/clang/tools/driver/driver.cpp:_ZL18getCLEnvVarOptionsRNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERN4llvm11StringSaverER
NS7_15SmallVectorImplIPKcEE:
    Hash: 0x0c17fbc6dd9a8e44
    Counters: 5
  _ZN4llvm15SmallVectorImplIPKcE6insertIPS2_vEES5_S5_T_S6_:
    Hash: 0x0dfbfcb43aa288bf
    Counters: 9
  _ZN4llvm15SmallVectorImplIPKcE6appendIPS2_vEEvT_S6_:
    Hash: 0x09b7820827e0a2a4
...
  _ZNK5clang17DiagnosticBuilderlsIPKcEERKS0_RKT_:
    Hash: 0x0ae15a44542b0f02
    Counters: 2
  _ZN5clang17DiagnosticBuilderC2EPNS_17DiagnosticsEngineE:
    Hash: 0x0f9bab17ad9a8e44
    Counters: 3
  _ZNSt3__120__shared_ptr_emplaceIN5clang22PCHContainerOperationsENS_9allocatorIS2_EEED2Ev:
    Hash: 0x0a4d0ad3efffffff
    Counters: 1
  _ZNSt3__120__shared_ptr_emplaceIN5clang22PCHContainerOperationsENS_9allocatorIS2_EEED0Ev:
    Hash: 0x0a4d0ad3efffffff
    Counters: 1
  _ZNSt3__120__shared_ptr_emplaceIN5clang22PCHContainerOperationsENS_9allocatorIS2_EEE16__on_zero_sharedEv:
    Hash: 0x0a4d0ad3efffffff
...

Reproducing the fault:
------------------------
Fist of all I apologise in advance for any formatting errors, this is my first github post...

I fetched the latest commits from llvm-project
# git rev-parse --verify HEAD
    97ebf67dbcbd76a36857b15c77521a7ddc224816

I built an instrumented clang (from a fully functional llvm-project from the same source) with LTO and libc++ (eating its own dogfood):
    # LLVM_DEFAULT_TARGET_TRIPLE tries to preserve triple so libs install correctly
    # LLVM_ENABLE_LIBCXX ensures llvm libraries are used
    # LLVM_ENABLE_LTO enable the thin link time optimisations
    # LLVM_TABLEGEN,CMAKE_AR,CMAKE_C_COMPILER etc. force ninja to use only llvm-project tools
    # CMAKE_C_FLAGS,CMAKE_CXX_FLAGS define the processor specific optimisations
    # CMAKE_EXE_LINKER_FLAGS ensures cmake compiler tests use llvm tools
'cmake',
    '-G',
    'Ninja',
    '-DLLVM_BUILD_INSTRUMENTED=IR',  
    '-DLLVM_BUILD_RUNTIME=OFF',          
    '-DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-linux-gnu',
    '-DLLVM_ENABLE_LIBCXX=ON',
    '-DLLVM_ENABLE_LTO=Thin',
    '-DLLVM_ENABLE_PIC=ON',
    '-DLLVM_ENABLE_PROJECTS=clang',
    '-DLLVM_INCLUDE_TESTS=OFF',
    '-DLLVM_PARALLEL_LINK_JOBS=4',
    '-DLLVM_TABLEGEN=' + DEFAULT_FUNCTIONAL + '/bin/llvm-tblgen',
    '-DLLVM_TARGETS_TO_BUILD=Native',
    '-DCMAKE_AR=' + DEFAULT_FUNCTIONAL + '/bin/llvm-ar',
    '-DCMAKE_BUILD_TYPE=Release',
    '-DCMAKE_C_COMPILER=' + DEFAULT_FUNCTIONAL + '/bin/clang',
    '-DCMAKE_C_FLAGS=-march=armv8-a+fp+simd+crc -mcpu=cortex-a72',
    '-DCMAKE_CXX_COMPILER=' + DEFAULT_FUNCTIONAL + '/bin/clang++',
    '-DCMAKE_CXX_FLAGS=-march=armv8-a+fp+simd+crc -mcpu=cortex-a72',
    '-DCMAKE_EXE_LINKER_FLAGS=-stdlib=libc++ -fuse-ld=lld',
    '-DCMAKE_NM=' + DEFAULT_FUNCTIONAL + '/bin/llvm-nm',
    '-DCMAKE_OBJCOPY=' + DEFAULT_FUNCTIONAL + '/bin/llvm-objcopy',
    '-DCMAKE_OBJDUMP=' + DEFAULT_FUNCTIONAL + '/bin/llvm-objdump',
    '-DCMAKE_RANLIB=' + DEFAULT_FUNCTIONAL + '/bin/llvm-ranlib',
    '-DCMAKE_STRIP=' + DEFAULT_FUNCTIONAL + '/bin/llvm-strip',
    '../llvm'

I then trained it (from the same source) with:
'cmake',
    '-G',
    'Ninja',
    '-DLLVM_BUILD_RUNTIME=OFF',  
    '-DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-linux-gnu',
    '-DLLVM_ENABLE_LIBCXX=ON',
    '-DLLVM_ENABLE_LTO=Thin',
    '-DLLVM_ENABLE_PIC=ON',
    '-DLLVM_ENABLE_PROJECTS=clang;lld',
    '-DLLVM_INCLUDE_TESTS=OFF',
    '-DLLVM_PARALLEL_LINK_JOBS=4',
    '-DLLVM_TABLEGEN=' + DEFAULT_FUNCTIONAL + '/bin/llvm-tblgen',
    '-DLLVM_TARGETS_TO_BUILD=Native',
    '-DCMAKE_AR=' + DEFAULT_FUNCTIONAL + '/bin/llvm-ar',
    '-DCMAKE_BUILD_TYPE=Release',
    '-DCMAKE_C_COMPILER=' + project + DEFAULT_INSTRUMENTED + '/bin/clang',
    '-DCMAKE_C_FLAGS=-march=armv8-a+fp+simd+crc -mcpu=cortex-a72',
    '-DCMAKE_CXX_COMPILER=' + project + DEFAULT_INSTRUMENTED + '/bin/clang++',
    '-DCMAKE_CXX_FLAGS=-march=armv8-a+fp+simd+crc -mcpu=cortex-a72',
    '-DCMAKE_EXE_LINKER_FLAGS=-stdlib=libc++ -fuse-ld=lld',
    '-DCMAKE_NM=' + DEFAULT_FUNCTIONAL + '/bin/llvm-nm',
    '-DCMAKE_OBJCOPY=' + DEFAULT_FUNCTIONAL + '/bin/llvm-objcopy',
    '-DCMAKE_OBJDUMP=' + DEFAULT_FUNCTIONAL + '/bin/llvm-objdump',
    '-DCMAKE_RANLIB=' + DEFAULT_FUNCTIONAL + '/bin/llvm-ranlib',
    '-DCMAKE_STRIP=' + DEFAULT_FUNCTIONAL + '/bin/llvm-strip',
    '../llvm'

In the instrumented build I find:
/git/llvm-project/instrumented# ls ./profiles/ -l
-rw-r--r-- 1 root root 15645256 Mar  1 18:05 default_1414596594604394224_0.profraw
-rw-r--r-- 1 root root      152 Mar  1 10:27 default_15853192585239873667_0.profraw
-rw-r--r-- 1 root root     2848 Mar  1 10:27 default_15854895753468332163_0.profraw
-rw-r--r-- 1 root root 49813488 Mar  3 07:36 default_487917923513444908_0.profraw
-rw-r--r-- 1 root root   908312 Mar  1 14:16 default_9345245229151225854_0.profraw

Attempting to merge the raw profile data produced many errors:
# llvm-profdata merge /git/llvm-project/instrumented/profiles/*.profraw --output=/git/llvm-project/instrumented/clang.profdata

/git/llvm-project/instrumented/profiles/default_487917923513444908_0.profraw: _ZNSt3__16vectorINS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS4_IS6_EEED2Ev: counter overflow
/git/llvm-project/instrumented/profiles/default_487917923513444908_0.profraw: _ZN5clang17DiagnosticBuilderD2Ev: counter overflow
/git/llvm-project/instrumented/profiles/default_487917923513444908_0.profraw: _ZN5clang19StreamingDiagnostic20DiagStorageAllocator8AllocateEv: counter overflow
/git/llvm-project/instrumented/profiles/default_487917923513444908_0.profraw: _ZN4llvm11SmallVectorIN5clang9FixItHintELj6EED2Ev: counter overflow
/git/llvm-project/instrumented/profiles/default_487917923513444908_0.profraw: _ZN5clang17DiagnosticOptionsC2Ev: counter overflow
/git/llvm-project/instrumented/profiles/default_487917923513444908_0.profraw: _ZN5clang17DiagnosticBuilderD2Ev: counter overflow
...

So I showed the funtions (top of the post) and noticed the many, many hash failures.
Please let me know If I have made a mistake or for more information. 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWl1zm7wS_jXOjcYeEN8XuXBsktI6tsd2On3fG0YIYdMCYoRwmvPrzwpsx26Nm-Scnjczpx4GiJCefbRadhdtIh4_Xd8_ofndDAnyiErBkzRjKCaSoA2pUFUnCROCxYhCUyUFLzcpVY82KCFpVgs26GnjnjZcbRj6AM09Y4i07xoxY43EBkvaH-KU1qJCOSmekExzVrWjdmdsoCzb5n0lv5Fdbfgj6uHbdSrhvH_2lVH1Z1oAkTpnhWQx_LkjXcFtzBJSZzI0XcfTHQ8blm6YpulpbqgNVD81yX6fZFk_qQsqU15USDFueYx4DZiigpa2AaHwb925Y9L_zmgtSZSxOZGb-ScaHfVBJxN3TeYlrsYIwzGhz32OwJGu7dtzkhZdUMwilmnHmu3FtuFY56GwdnjQpS-akWINV8l51mhJpFsmDjcDWpaAFP490c12nmw00lfQeTE1FZRuLXNQ2WdA4yLIyywABfh-F20nNnXL011Xp7buxh0aMP57rN01k6OJX2w_EzErm0VdTJfSCENdxxGpUhqCwaTFOqDTJbTRDRGhFCSVVQDzgDYPpsfBwmF60OD7-4nry2bckoBAf9Eyni6d8JUaobqTRNSOY4-4zDTPa8R6NrlLarfB-pmQwXyJw63vL60QjlW4tMMu6XESJTQyDUKw60bJeeneC6WTsmRFvJe-vSjYixwXay52mEYw2U17MBgcifpkNcusO-OUrAteyZTe1GkWM5FVrU4Xn5ZauPi06pRCmG4R07RMHGmJhjvekiOZnSJH2J8rAzl6UvnFOi1Y58omXkQi3SEXV9Y4Et6aJdbCsAIrZHFYShEyUC-hLNhRw3g--jDihQTfwMCimSCNU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