llvm-project
289bef69 - [PseudoProbe] Include function hash in descriptor COMDAT key (#190296)

Commit
131 days ago
[PseudoProbe] Include function hash in descriptor COMDAT key (#190296) The .pseudo_probe_desc section uses COMDAT to deduplicate descriptors for the same function across translation units. On COFF, the COMDAT key is uniquely determined by the function name. The COMDAT selection type is EXACT_MATCH, which requires byte-identical content. This holds for applications that strictly follow C/C++ ODR rules. Unfortunately, we consistently observe .pseudo_probe_desc COMDAT duplicate symbol errors on Windows (see also #177540). Most of them are due to hash mismatches, meaning two non-internal functions with the same name but different bodies — a violation of ODR rules. Some of these functions are generated by the compiler (e.g., TU-local optimizations that alter the CFG of a linkonce_odr function), and some are caused by source code issues (e.g., different preprocessor settings or optimization pragmas across TUs). It is hard to fix all of them, but they seriously affect the user experience of using pseudo probe on Windows due to the endless COFF COMDAT symbol duplication errors. Users have to resort to /force:multiple, which may hide other issues. This patch includes the function hash in the COMDAT key for .pseudo_probe_desc sections on both ELF and COFF. Descriptors with different hashes now get separate COMDAT sections to avoiding linker errors. To help users identify functions affected by cross-TU inconsistencies, MCPseudoProbe now detects duplicate GUIDs with mismatching hashes during pseudo probe decoding. A summary count is printed by default; users can also use llvm-profgen's --show-detailed-warning for per-function details.
Author
Parents
Loading