LTO ensures consistent alias sets for _BitInt types
LTO now correctly assigns consistent alias sets to signed and unsigned _BitInt types of the same precision.
This commit resolves an issue in Link-Time Optimization (LTO) where signed and unsigned _BitInt types of the same precision were not guaranteed to have the same alias set. This could lead to incorrect aliasing analysis. The fix is applied during canonical type merging, ensuring that these types are treated consistently, unlike the previous approach that relied on c_common_get_alias_set which is complicated by LTO’s streaming mechanism. A new test case validates this correction.
In Details
This patch fixes an LTO issue where signed and unsigned _BitInt types of identical precision were not assigned the same alias set. c_common_get_alias_set normally ensures this by referencing other signedness variants, but LTO's streaming and the bitint_type_cache not being populated prevent this direct approach. The fix is implemented in type_with_interoperable_signedness and gimple_signed_or_unsigned_type during canonical type merging. gimple_get_alias_set is also updated with a comment.
- Link-Time Optimization (LTO)
- A compiler optimization technique where the optimization process is deferred until link time. This allows the linker to have visibility across multiple translation units, enabling more aggressive optimizations that consider the entire program.
- _BitInt
- A non-standard integer type in C/C++ that allows specifying arbitrary bit widths for integers. For example,
_BitInt(7)declares an integer with 7 bits. - Alias Set
- In the context of memory access, an alias set is a group of memory locations that are known not to overlap. The compiler uses alias analysis to determine if two pointers can point to the same memory location, which is crucial for optimization.
- Canonical Type Merging
- A process within the compiler where type information from different sources or representations is unified into a single, canonical form. This ensures consistency, especially in scenarios like LTO where information from multiple compilation units is combined.