[llvm] [clang] [compiler-rt] [Profile] Refactor profile correlation. (PR #70856)

Petr Hosek via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 2 13:04:52 PDT 2023


petrhosek wrote:

I'm a bit concerned about the use of `hasCorrelation`. We require the runtime to check the flag and omit the data and names section if set which introduces a potential issue: since we emit the version in every TU and u se COMDAT to deduplicate them, but that means that if you link together TUs compiled with and without `-debug-info-correlate`/`-profile-correlate=` (that is having different flags), you would end up with different results depending on which section was selected by the linker. This may not be an issue if you always compile all code yourself using the same set of flags, but might be an issue when you combine libraries coming from different sources.

What I think would be a better design is to just omit the respective sections altogether when `-debug-info-correlate`/`-profile-correlate=` is enabled. Then in `llvm-profdata` we would use the correlation as a fallback mechanism, that is if the data or names are present in the profile, just use it, otherwise fallback either to debug info or unstripped file (you could even support a combination of both). That way we wouldn't even need flags like `VARIANT_MASK_DBG_CORRELATE`. 

https://github.com/llvm/llvm-project/pull/70856


More information about the cfe-commits mailing list