[profile] Fix file contention causing dropped counts on Windows under -fprofile-generate

See PR43425:
https://bugs.llvm.org/show_bug.cgi?id=43425

When writing profile data on Windows we were opening profile file with
exclusive read/write access.

In case we are trying to write to the file from multiple processes
simultaneously, subsequent calls to CreateFileA would return
INVALID_HANDLE_VALUE.

To fix this, I changed to open without exclusive access and then take a
lock.

Patch by Michael Holman!

Differential revision: https://reviews.llvm.org/D70330

(cherry picked from commit 900d8a9a3b4efeefddd310e92219741d98e7270b)
4 files changed
tree: 397479a3271a09dfae0be95e9661cb2f6be5237d
  1. .github/
  2. clang/
  3. clang-tools-extra/
  4. compiler-rt/
  5. debuginfo-tests/
  6. libclc/
  7. libcxx/
  8. libcxxabi/
  9. libunwind/
  10. lld/
  11. lldb/
  12. llgo/
  13. llvm/
  14. openmp/
  15. parallel-libs/
  16. polly/
  17. pstl/
  18. .arcconfig
  19. .clang-format
  20. .clang-tidy
  21. .gitignore
  22. README.md
README.md

The LLVM Compiler Infrastructure

This directory and its subdirectories contain source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and runtime environments.