[all-commits] [llvm/llvm-project] 4dbf3f: [LangRef] Require i8s to be naturally aligned

Jannik Silvanus via All-commits all-commits at lists.llvm.org
Mon Jan 23 00:36:22 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4dbf3f2e8e72472161223d084c5646b76cc41d63
      https://github.com/llvm/llvm-project/commit/4dbf3f2e8e72472161223d084c5646b76cc41d63
  Author: Jannik Silvanus <jannik.silvanus at amd.com>
  Date:   2023-01-23 (Mon, 23 Jan 2023)

  Changed paths:
    M llvm/docs/LangRef.rst
    M llvm/lib/IR/DataLayout.cpp
    A llvm/test/Assembler/datalayout-invalid-i8-alignment.ll

  Log Message:
  -----------
  [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 (df1a74a) 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




More information about the All-commits mailing list