[LangRef] Require i8s to be naturally aligned
It is widely assumed that i8 is naturally aligned (i8:8), and that hence i8s can be used to access arbitrary bytes. As discussed in https://discourse.llvm.org/t/status-of-overaligned-i8, this patch makes this assumption explicit, by documenting it in the LangRef, and enforcing it when parsing a data layout string. Historically, there have been data layouts that violate this requirement, notably the old DXIL data layout that aligns i8 to 32 bits. A previous patch (df1a74ac) enabled importing modules with invalid data layouts using override callbacks. Users who wish to continue importing modules with overaligned i8s (e.g. DXIL) thus need to provide a data layout override callback that fixes the data layout, at minimum by setting natural alignment for i8. Any further adjustments to the module (e.g. adding padding bytes if necessary) need to be done after module import. In the case of DXIL, this should not be necessary, because i8 usage in DXIL is very limited and its alignment actually does not matter, see https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst#primitive-types Differential Revision: https://reviews.llvm.org/D142211
Loading
Please sign in to comment