[PATCH] D142211: [LangRef] Require i8s to be naturally aligned

Jannik Silvanus via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 23 00:36:21 PST 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4dbf3f2e8e72: [LangRef] Require i8s to be naturally aligned (authored by jsilvanus).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142211/new/

https://reviews.llvm.org/D142211

Files:
  llvm/docs/LangRef.rst
  llvm/lib/IR/DataLayout.cpp
  llvm/test/Assembler/datalayout-invalid-i8-alignment.ll


Index: llvm/test/Assembler/datalayout-invalid-i8-alignment.ll
===================================================================
--- /dev/null
+++ llvm/test/Assembler/datalayout-invalid-i8-alignment.ll
@@ -0,0 +1,5 @@
+; RUN: not llvm-as %s 2>&1 | FileCheck %s
+
+; CHECK: error: Invalid ABI alignment, i8 must be naturally aligned
+
+target datalayout = "i8:16"
Index: llvm/lib/IR/DataLayout.cpp
===================================================================
--- llvm/lib/IR/DataLayout.cpp
+++ llvm/lib/IR/DataLayout.cpp
@@ -406,6 +406,9 @@
         return reportError("Invalid ABI alignment, must be a 16bit integer");
       if (ABIAlign != 0 && !isPowerOf2_64(ABIAlign))
         return reportError("Invalid ABI alignment, must be a power of 2");
+      if (AlignType == INTEGER_ALIGN && Size == 8 && ABIAlign != 1)
+        return reportError(
+            "Invalid ABI alignment, i8 must be naturally aligned");
 
       // Preferred alignment.
       unsigned PrefAlign = ABIAlign;
Index: llvm/docs/LangRef.rst
===================================================================
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -2772,6 +2772,8 @@
     This specifies the alignment for an integer type of a given bit
     ``<size>``. The value of ``<size>`` must be in the range [1,2^23).
     ``<pref>`` is optional and defaults to ``<abi>``.
+    For ``i8``, the ``<abi>`` value must equal 8,
+    that is, ``i8`` must be naturally aligned.
 ``v<size>:<abi>[:<pref>]``
     This specifies the alignment for a vector type of a given bit
     ``<size>``. The value of ``<size>`` must be in the range [1,2^23).
@@ -2839,7 +2841,7 @@
    same as the default address space.
 -  ``S0`` - natural stack alignment is unspecified
 -  ``i1:8:8`` - i1 is 8-bit (byte) aligned
--  ``i8:8:8`` - i8 is 8-bit (byte) aligned
+-  ``i8:8:8`` - i8 is 8-bit (byte) aligned as mandated
 -  ``i16:16:16`` - i16 is 16-bit aligned
 -  ``i32:32:32`` - i32 is 32-bit aligned
 -  ``i64:32:64`` - i64 has ABI alignment of 32-bits but preferred


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142211.491243.patch
Type: text/x-patch
Size: 2036 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230123/59dd8f56/attachment.bin>


More information about the llvm-commits mailing list