[clang] [CIR] Return power-of-two ABI alignment for non-fundamental int widths (PR #210187)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 16 14:54:14 PDT 2026


================
@@ -809,7 +809,13 @@ uint64_t IntType::getABIAlignment(const mlir::DataLayout &dataLayout,
         std::min(llvm::PowerOf2Ceil(width), static_cast<uint64_t>(64));
     return std::max(alignBits / 8, static_cast<uint64_t>(1));
   }
-  return (uint64_t)(width / 8);
+  // Round up to a power-of-two byte alignment.  DataLayout consumers such as
+  // llvm::Align require power-of-two alignments, and width / 8 is not a power
+  // of two for non-fundamental widths (e.g. i24 -> 3).  This leaves the
----------------
andykaylor wrote:

Can we ever get an i24 value that isn't a BitInt apart from hand-written tests? This is probably a good fallback to have anyway (as demonstrated by the fact that you ran into it in your ABI work), but it seems like an odd case.

https://github.com/llvm/llvm-project/pull/210187


More information about the cfe-commits mailing list