[InstrProf] Fix bug when merging empty profile with multiple threads
authorEllis Hoag <ellis.sparky.hoag@gmail.com>
Sat, 10 Dec 2022 01:12:30 +0000 (17:12 -0800)
committerEllis Hoag <ellis.sparky.hoag@gmail.com>
Mon, 12 Dec 2022 17:23:26 +0000 (09:23 -0800)
commit769c7ad2b1b9bca7e13cf6211e9d61439f6df8d6
treee93b6edaeadbc8948cfaa4df3c5bee13396a7119
parentce932556af10767a3da84fc1ad0e36a0a4f3eefa
[InstrProf] Fix bug when merging empty profile with multiple threads

When merging profiles with multiple threads, the `mergeWriterContexts()` function is used to merge profile data between writers. This must be in sync with `loadInput()` which merges profiles to a single writer. This diff merges the profile kind correctly in `mergeWriterContexts()` to fix a subtle bug.

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D139755
llvm/test/tools/llvm-profdata/merge-incompatible.test
llvm/test/tools/llvm-profdata/merge_empty_profile.test
llvm/tools/llvm-profdata/llvm-profdata.cpp