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

    <tr>
        <th>Summary</th>
        <td>
            Online merging of raw profile data fails with clang-cl on windows
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          wdunicornpro
      </td>
    </tr>
</table>

<pre>
    Source-based coverage caused build failure when building with clang-cl but seems to work fine when building with plain clang and clang++.

Possible cause is that the binaries built with clang-cl failed to do online merging.

Profile data from multiple runs of the same binary should be automatically merged through online merging: https://clang.llvm.org/docs/UsersManual.html#profiling-with-instrumentation

> Additionally, multiple raw profiles dumped from different processes that share a file system (can be on different hosts) will be automatically merged by the profiler runtime during the dumping.

But the llvm-min-tblgen.exe built with clang-cl + source coverage fails when profile data already exists from a previous run:

```
$ D:\Dev\llvm-project\build\bin\llvm-min-tblgen.exe -gen-intrinsic-enums -intrinsic-prefix=mips -I D:/Dev/llvm-project/llvm/include/llvm/IR -ID:/Dev/llvm-project/build/include -ID:/Dev/llvm-project/llvm/include D:/Dev/llvm-project/llvm/include/llvm/IR/Intrinsics.td --write-if-changed -o include/llvm/IR/IntrinsicsMips.h -d include/llvm/IR/IntrinsicsMips.h.d" 
# generates 15823075377192752634_0.profraw
$ echo %errorlevel%
 0

$ D:\Dev\llvm-project\build\bin\llvm-min-tblgen.exe -gen-intrinsic-enums -intrinsic-prefix=mips -I D:/Dev/llvm-project/llvm/include/llvm/IR -ID:/Dev/llvm-project/build/include -ID:/Dev/llvm-project/llvm/include D:/Dev/llvm-project/llvm/include/llvm/IR/Intrinsics.td --write-if-changed -o include/llvm/IR/IntrinsicsMips.h -d include/llvm/IR/IntrinsicsMips.h.d"
$ echo %errorlevel%
   -1073741795
```
However, plain clang and clang++ does not have this issue.

To reproduce:
On `master`, build LLVM with [the latest release of clang toolchain](https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.3/LLVM-16.0.3-win64.exe) and source code coverage enabled: 
```
$ cmake -S llvm -B build -G Ninja -DLLVM_BUILD_INSTRUMENTED_COVERAGE=1 -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang-cl.exe" -DCMAKE_C_COMPILER="C:/Program Files/LLVM/bin/clang-cl.exe" -DCMAKE_MT="C:/Program Files (x86)/Windows Kits/10/bin/10.0.22000.0/x64/mt.exe"
$ cd build && ninja check-all
```

Console output:
```
[1/3298] Building GenVT.inc...
FAILED: include/llvm/CodeGen/GenVT.inc
cmd.exe /C "cd /D D:\Dev\llvm-project\build && D:\Dev\llvm-project\build\bin\llvm-min-tblgen.exe -gen-vt -I D:/Dev/llvm-project/llvm/include/llvm/CodeGen -ID:/Dev/llvm-project/build/include -ID:/Dev/llvm-project/llvm/include D:/Dev/llvm-project/llvm/include/llvm/CodeGen/ValueTypes.td --write-if-changed -o include/llvm/CodeGen/GenVT.inc -d include/llvm/CodeGen/GenVT.inc.d"
[3/3298] Building IntrinsicsBPF.h...
FAILED: include/llvm/IR/IntrinsicsBPF.h
cmd.exe /C "cd /D D:\Dev\llvm-project\build && D:\Dev\llvm-project\build\bin\llvm-min-tblgen.exe -gen-intrinsic-enums -intrinsic-prefix=bpf -I D:/Dev/llvm-project/llvm/include/llvm/IR -ID:/Dev/llvm-project/build/include -ID:/Dev/llvm-project/llvm/include D:/Dev/llvm-project/llvm/include/llvm/IR/Intrinsics.td --write-if-changed -o include/llvm/IR/IntrinsicsBPF.h -d include/llvm/IR/IntrinsicsBPF.h.d"
[4/3298] Building IntrinsicsHexagon.h...
FAILED: include/llvm/IR/IntrinsicsHexagon.h
cmd.exe /C "cd /D D:\Dev\llvm-project\build && D:\Dev\llvm-project\build\bin\llvm-min-tblgen.exe -gen-intrinsic-enums -intrinsic-prefix=hexagon -I D:/Dev/llvm-project/llvm/include/llvm/IR -ID:/Dev/llvm-project/build/include -ID:/Dev/llvm-project/llvm/include D:/Dev/llvm-project/llvm/include/llvm/IR/Intrinsics.td --write-if-changed -o include/llvm/IR/IntrinsicsHexagon.h -d include/llvm/IR/IntrinsicsHexagon.h.d"
[5/3298] Building IntrinsicsLoongArch.h...
FAILED: include/llvm/IR/IntrinsicsLoongArch.h
cmd.exe /C "cd /D D:\Dev\llvm-project\build && D:\Dev\llvm-project\build\bin\llvm-min-tblgen.exe -gen-intrinsic-enums -intrinsic-prefix=loongarch -I D:/Dev/llvm-project/llvm/include/llvm/IR -ID:/Dev/llvm-project/build/include -ID:/Dev/llvm-project/llvm/include D:/Dev/llvm-project/llvm/include/llvm/IR/Intrinsics.td --write-if-changed -o include/llvm/IR/IntrinsicsLoongArch.h -d include/llvm/IR/IntrinsicsLoongArch.h.d"
[6/3298] Building IntrinsicsARM.h...
FAILED: include/llvm/IR/IntrinsicsARM.h
cmd.exe /C "cd /D D:\Dev\llvm-project\build && D:\Dev\llvm-project\build\bin\llvm-min-tblgen.exe -gen-intrinsic-enums -intrinsic-prefix=arm -I D:/Dev/llvm-project/llvm/include/llvm/IR -ID:/Dev/llvm-project/build/include -ID:/Dev/llvm-project/llvm/include D:/Dev/llvm-project/llvm/include/llvm/IR/Intrinsics.td --write-if-changed -o include/llvm/IR/IntrinsicsARM.h -d include/llvm/IR/IntrinsicsARM.h.d"
[7/3298] Building IntrinsicsNVPTX.h...
FAILED: include/llvm/IR/IntrinsicsNVPTX.h
cmd.exe /C "cd /D D:\Dev\llvm-project\build && D:\Dev\llvm-project\build\bin\llvm-min-tblgen.exe -gen-intrinsic-enums -intrinsic-prefix=nvvm -I D:/Dev/llvm-project/llvm/include/llvm/IR -ID:/Dev/llvm-project/build/include -ID:/Dev/llvm-project/llvm/include D:/Dev/llvm-project/llvm/include/llvm/IR/Intrinsics.td --write-if-changed -o include/llvm/IR/IntrinsicsNVPTX.h -d include/llvm/IR/IntrinsicsNVPTX.h.d" 
[8/3298] Building IntrinsicsDirectX.h...
FAILED: include/llvm/IR/IntrinsicsDirectX.h
cmd.exe /C "cd /D D:\Dev\llvm-project\build && D:\Dev\llvm-project\build\bin\llvm-min-tblgen.exe -gen-intrinsic-enums -intrinsic-prefix=dx -I D:/Dev/llvm-project/llvm/include/llvm/IR -ID:/Dev/llvm-project/build/include -ID:/Dev/llvm-project/llvm/include D:/Dev/llvm-project/llvm/include/llvm/IR/Intrinsics.td --write-if-changed -o include/llvm/IR/IntrinsicsDirectX.h -d include/llvm/IR/IntrinsicsDirectX.h.d"  
[9/3298] Building IntrinsicsPowerPC.h...
FAILED: include/llvm/IR/IntrinsicsPowerPC.h
cmd.exe /C "cd /D D:\Dev\llvm-project\build && D:\Dev\llvm-project\build\bin\llvm-min-tblgen.exe -gen-intrinsic-enums -intrinsic-prefix=ppc -I D:/Dev/llvm-project/llvm/include/llvm/IR -ID:/Dev/llvm-project/build/include -ID:/Dev/llvm-project/llvm/include D:/Dev/llvm-project/llvm/include/llvm/IR/Intrinsics.td --write-if-changed -o include/llvm/IR/IntrinsicsPowerPC.h -d include/llvm/IR/IntrinsicsPowerPC.h.d" 
[10/3298] Building IntrinsicsMips.h...
FAILED: include/llvm/IR/IntrinsicsMips.h
cmd.exe /C "cd /D D:\Dev\llvm-project\build && D:\Dev\llvm-project\build\bin\llvm-min-tblgen.exe -gen-intrinsic-enums -intrinsic-prefix=mips -I D:/Dev/llvm-project/llvm/include/llvm/IR -ID:/Dev/llvm-project/build/include -ID:/Dev/llvm-project/llvm/include D:/Dev/llvm-project/llvm/include/llvm/IR/Intrinsics.td --write-if-changed -o include/llvm/IR/IntrinsicsMips.h -d include/llvm/IR/IntrinsicsMips.h.d" 
[11/3298] Building IntrinsicsS390.h...
FAILED: include/llvm/IR/IntrinsicsS390.h
cmd.exe /C "cd /D D:\Dev\llvm-project\build && D:\Dev\llvm-project\build\bin\llvm-min-tblgen.exe -gen-intrinsic-enums -intrinsic-prefix=s390 -I D:/Dev/llvm-project/llvm/include/llvm/IR -ID:/Dev/llvm-project/build/include -ID:/Dev/llvm-project/llvm/include D:/Dev/llvm-project/llvm/include/llvm/IR/Intrinsics.td --write-if-changed -o include/llvm/IR/IntrinsicsS390.h -d include/llvm/IR/IntrinsicsS390.h.d" 
[12/3298] Building IntrinsicEnums.inc...
FAILED: include/llvm/IR/IntrinsicEnums.inc
cmd.exe /C "cd /D D:\Dev\llvm-project\build && D:\Dev\llvm-project\build\bin\llvm-min-tblgen.exe -gen-intrinsic-enums -I D:/Dev/llvm-project/llvm/include/llvm/IR -ID:/Dev/llvm-project/build/include -ID:/Dev/llvm-project/llvm/include D:/Dev/llvm-project/llvm/include/llvm/IR/Intrinsics.td --write-if-changed -o include/llvm/IR/IntrinsicEnums.inc -d include/llvm/IR/IntrinsicEnums.inc.d"
[13/3298] Building IntrinsicsR600.h...
FAILED: include/llvm/IR/IntrinsicsR600.h
cmd.exe /C "cd /D D:\Dev\llvm-project\build && D:\Dev\llvm-project\build\bin\llvm-min-tblgen.exe -gen-intrinsic-enums -intrinsic-prefix=r600 -I D:/Dev/llvm-project/llvm/include/llvm/IR -ID:/Dev/llvm-project/build/include -ID:/Dev/llvm-project/llvm/include D:/Dev/llvm-project/llvm/include/llvm/IR/Intrinsics.td --write-if-changed -o include/llvm/IR/IntrinsicsR600.h -d include/llvm/IR/IntrinsicsR600.h.d" 
[14/3298] Building IntrinsicsAMDGPU.h...
FAILED: include/llvm/IR/IntrinsicsAMDGPU.h
cmd.exe /C "cd /D D:\Dev\llvm-project\build && D:\Dev\llvm-project\build\bin\llvm-min-tblgen.exe -gen-intrinsic-enums -intrinsic-prefix=amdgcn -I D:/Dev/llvm-project/llvm/include/llvm/IR -ID:/Dev/llvm-project/build/include -ID:/Dev/llvm-project/llvm/include D:/Dev/llvm-project/llvm/include/llvm/IR/Intrinsics.td --write-if-changed -o include/llvm/IR/IntrinsicsAMDGPU.h -d include/llvm/IR/IntrinsicsAMDGPU.h.d"[15/3298] Building IntrinsicsAArch64.h...
FAILED: include/llvm/IR/IntrinsicsAArch64.h
cmd.exe /C "cd /D D:\Dev\llvm-project\build && D:\Dev\llvm-project\build\bin\llvm-min-tblgen.exe -gen-intrinsic-enums -intrinsic-prefix=aarch64 -I D:/Dev/llvm-project/llvm/include/llvm/IR -ID:/Dev/llvm-project/build/include -ID:/Dev/llvm-project/llvm/include D:/Dev/llvm-project/llvm/include/llvm/IR/Intrinsics.td --write-if-changed -o include/llvm/IR/IntrinsicsAArch64.h -d include/llvm/IR/IntrinsicsAArch64.h.d"
[16/3298] Building IntrinsicsRISCV.h...
FAILED: include/llvm/IR/IntrinsicsRISCV.h
cmd.exe /C "cd /D D:\Dev\llvm-project\build && D:\Dev\llvm-project\build\bin\llvm-min-tblgen.exe -gen-intrinsic-enums -intrinsic-prefix=riscv -I D:/Dev/llvm-project/llvm/include/llvm/IR -ID:/Dev/llvm-project/build/include -ID:/Dev/llvm-project/llvm/include D:/Dev/llvm-project/llvm/include/llvm/IR/Intrinsics.td --write-if-changed -o include/llvm/IR/IntrinsicsRISCV.h -d include/llvm/IR/IntrinsicsRISCV.h.d" 
[17/3298] Building IntrinsicsSPIRV.h...
FAILED: include/llvm/IR/IntrinsicsSPIRV.h
cmd.exe /C "cd /D D:\Dev\llvm-project\build && D:\Dev\llvm-project\build\bin\llvm-min-tblgen.exe -gen-intrinsic-enums -intrinsic-prefix=spv -I D:/Dev/llvm-project/llvm/include/llvm/IR -ID:/Dev/llvm-project/build/include -ID:/Dev/llvm-project/llvm/include D:/Dev/llvm-project/llvm/include/llvm/IR/Intrinsics.td --write-if-changed -o include/llvm/IR/IntrinsicsSPIRV.h -d include/llvm/IR/IntrinsicsSPIRV.h.d" 
[18/3298] Building IntrinsicImpl.inc...
FAILED: include/llvm/IR/IntrinsicImpl.inc
cmd.exe /C "cd /D D:\Dev\llvm-project\build && D:\Dev\llvm-project\build\bin\llvm-min-tblgen.exe -gen-intrinsic-impl -I D:/Dev/llvm-project/llvm/include/llvm/IR -ID:/Dev/llvm-project/build/include -ID:/Dev/llvm-project/llvm/include D:/Dev/llvm-project/llvm/include/llvm/IR/Intrinsics.td --write-if-changed -o include/llvm/IR/IntrinsicImpl.inc -d include/llvm/IR/IntrinsicImpl.inc.d"
ninja: build stopped: subcommand failed.
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsm1tv4jwTxz-NubESBYeEcsEFh9IHPe1u1Xb77l1lkiHxrmNHtgPtt3_lJBwfoFm0F0VCWrHNYeyZ-f-YARNTrVkiAPooGKJg3KKFSaXqL-NCsEgqkSvZmsn4o_8sCxWBM6MaYhzJBSiaAI5oYY9nBeMxnlPGCwV4mYKoTjGR4CUzKY44FYkTcTwrDNYAmcZG4qVUv_GciYMmOadMVIaYirj6C5EhIkMXeWPkDarXR6k1m_HaF8w0Nik12KSAZ0xQxUCXI5s9T6y3EFs3Yoml4NaNDFTCRLI7vpJzxgHH1FA8VzLDWcENyzlgVQiN5bycS9OsnvAD61QWPMYzwLQwMqOGRZTzj3J4O2WqZJGke5Mif4BTY3KN_AEiE0Qmpasu54vMlSpBZBLLSCMy-aFB6QcqCsrd1GQcET8vnWQicWyQDhPaqCIDYahhUmyHg_xbPIhjZs9bpxAZbQVEl7gaCjSOiyyHuAo5ZvM5KBDGXo5Aa6jTrFOqAFNcpkh_aAMZRuQmosKGL8WWZSq10Yj08JJxfjQ5s48ynbUXyubYsAxwXCiLhr1mHdtXaVhUkttsORkTjpnxBIQL73BQfUSGWJdIb2C2ROgKxXxbdMoV0PgDwzvTRlcJoThXsGCy0NZDK9l2jkOv_lcdkg4e21uC0RgWKBiVTuZK_oLIoGBUcm__Z2J1cS8CJwHhMGEUE5pFDogi03jrRK5gzt6RP85YrrEzraYjEzsdmexMVx0iMmEi4kUMmxPTJ-xMTxlWfq4tP7l7d5ozPbIvqyi1a2LsOEvFDDhs7kQpFZYYR-LPLB9Yrt0UO3HDO90YEYJX6vk4AQGKGtC4HdwQ3-sGfrfb7pFuQEK_8-a5lhdFlxu9IUolRiQApaTisACOSFBdxt4OK1c4LhG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