With PGO, the instrumented binary needs to dump llvm_prf_data, llvm_prf_cnts, and llvm_prf_names data sections. The runtime needs to figure out the start and end addresses of the sections. The way it is implemented for Linux is emit function calls during start up time to register the llvm_profile_data variables created for the functions, and runtime library tracks the start and end. On Darwin, special section symbol is used so this is avoided.
This is not only inefficient, but also wastes lots of space in text.
This patch proposes using linker script to solve the problem. The changes in clang FE is basically refactoring. The core changes are in projects/compiler_rt/profile and llvm.
Please add a driver test for this change.