[clang] [CIR] React to breaking change to DataLayoutTypeInterface (PR #128772)

David Olsen via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 25 12:56:28 PST 2025


https://github.com/dkolsen-pgi created https://github.com/llvm/llvm-project/pull/128772

In #128754, `DataLayoutTypeInterface` was changed to give `getPreferredAlignment` a default implemention.  As a result, table-gen no longer declared `getPreferredAlignment` when defining a class that contained `[DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]` in the table-gen definition.  That means all of the definitions in `CIRTypes.cpp`, such as `PointerType::getPreferredAligment`, were compilation errors.

Delete all the definitions of `getPreferredAlignment`.  I verified that the default implementation does the exact same thing as the explicit overrides that are being deleted.

>From f1c826d6ed0e1337271680509ef9d3a3a6108c53 Mon Sep 17 00:00:00 2001
From: David Olsen <dolsen at nvidia.com>
Date: Tue, 25 Feb 2025 12:44:33 -0800
Subject: [PATCH] [CIR] React to breaking change to DataLayoutTypeInterface

In #128754, `DataLayoutTypeInterface` was changed to give
`getPreferredAlignment` a default implemention.  As a result, table-gen
no longer declared `getPreferredAlignment` when defining a class that
contained `[DeclareTypeInterfaceMethods<DataLayoutTypeInterface>]` in
the table-gen definition.  That means all of the definitions in
`CIRTypes.cpp`, such as `PointerType::getPreferredAligment`, were
compilation errors.

Delete all the definitions of `getPreferredAlignment`.  I verified that
the default implementation does the exact same thing as the explicit
overrides that are being deleted.
---
 clang/lib/CIR/Dialect/IR/CIRTypes.cpp | 62 ---------------------------
 1 file changed, 62 deletions(-)

diff --git a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp
index f3349250f2205..d1b143efb955e 100644
--- a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp
@@ -125,12 +125,6 @@ uint64_t IntType::getABIAlignment(const mlir::DataLayout &dataLayout,
   return (uint64_t)(getWidth() / 8);
 }
 
-uint64_t
-IntType::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                               ::mlir::DataLayoutEntryListRef params) const {
-  return (uint64_t)(getWidth() / 8);
-}
-
 mlir::LogicalResult
 IntType::verify(llvm::function_ref<mlir::InFlightDiagnostic()> emitError,
                 unsigned width, bool isSigned) {
@@ -163,12 +157,6 @@ SingleType::getABIAlignment(const mlir::DataLayout &dataLayout,
   return (uint64_t)(getWidth() / 8);
 }
 
-uint64_t
-SingleType::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                                  ::mlir::DataLayoutEntryListRef params) const {
-  return (uint64_t)(getWidth() / 8);
-}
-
 const llvm::fltSemantics &DoubleType::getFloatSemantics() const {
   return llvm::APFloat::IEEEdouble();
 }
@@ -185,12 +173,6 @@ DoubleType::getABIAlignment(const mlir::DataLayout &dataLayout,
   return (uint64_t)(getWidth() / 8);
 }
 
-uint64_t
-DoubleType::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                                  ::mlir::DataLayoutEntryListRef params) const {
-  return (uint64_t)(getWidth() / 8);
-}
-
 const llvm::fltSemantics &FP16Type::getFloatSemantics() const {
   return llvm::APFloat::IEEEhalf();
 }
@@ -206,12 +188,6 @@ uint64_t FP16Type::getABIAlignment(const mlir::DataLayout &dataLayout,
   return (uint64_t)(getWidth() / 8);
 }
 
-uint64_t
-FP16Type::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                                ::mlir::DataLayoutEntryListRef params) const {
-  return (uint64_t)(getWidth() / 8);
-}
-
 const llvm::fltSemantics &BF16Type::getFloatSemantics() const {
   return llvm::APFloat::BFloat();
 }
@@ -227,12 +203,6 @@ uint64_t BF16Type::getABIAlignment(const mlir::DataLayout &dataLayout,
   return (uint64_t)(getWidth() / 8);
 }
 
-uint64_t
-BF16Type::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                                ::mlir::DataLayoutEntryListRef params) const {
-  return (uint64_t)(getWidth() / 8);
-}
-
 const llvm::fltSemantics &FP80Type::getFloatSemantics() const {
   return llvm::APFloat::x87DoubleExtended();
 }
@@ -249,12 +219,6 @@ uint64_t FP80Type::getABIAlignment(const mlir::DataLayout &dataLayout,
   return 16;
 }
 
-uint64_t
-FP80Type::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                                ::mlir::DataLayoutEntryListRef params) const {
-  return 16;
-}
-
 const llvm::fltSemantics &FP128Type::getFloatSemantics() const {
   return llvm::APFloat::IEEEquad();
 }
@@ -270,12 +234,6 @@ uint64_t FP128Type::getABIAlignment(const mlir::DataLayout &dataLayout,
   return 16;
 }
 
-uint64_t
-FP128Type::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                                 ::mlir::DataLayoutEntryListRef params) const {
-  return 16;
-}
-
 const llvm::fltSemantics &LongDoubleType::getFloatSemantics() const {
   return mlir::cast<cir::CIRFPTypeInterface>(getUnderlying())
       .getFloatSemantics();
@@ -295,13 +253,6 @@ LongDoubleType::getABIAlignment(const mlir::DataLayout &dataLayout,
       .getABIAlignment(dataLayout, params);
 }
 
-uint64_t LongDoubleType::getPreferredAlignment(
-    const ::mlir::DataLayout &dataLayout,
-    mlir::DataLayoutEntryListRef params) const {
-  return mlir::cast<mlir::DataLayoutTypeInterface>(getUnderlying())
-      .getPreferredAlignment(dataLayout, params);
-}
-
 LogicalResult
 LongDoubleType::verify(function_ref<InFlightDiagnostic()> emitError,
                        mlir::Type underlying) {
@@ -397,12 +348,6 @@ BoolType::getABIAlignment(const ::mlir::DataLayout &dataLayout,
   return 1;
 }
 
-uint64_t
-BoolType::getPreferredAlignment(const ::mlir::DataLayout &dataLayout,
-                                ::mlir::DataLayoutEntryListRef params) const {
-  return 1;
-}
-
 //===----------------------------------------------------------------------===//
 // PointerType Definitions
 //===----------------------------------------------------------------------===//
@@ -421,13 +366,6 @@ PointerType::getABIAlignment(const ::mlir::DataLayout &dataLayout,
   return 8;
 }
 
-uint64_t PointerType::getPreferredAlignment(
-    const ::mlir::DataLayout &dataLayout,
-    ::mlir::DataLayoutEntryListRef params) const {
-  // FIXME: improve this in face of address spaces
-  return 8;
-}
-
 mlir::LogicalResult
 PointerType::verify(llvm::function_ref<mlir::InFlightDiagnostic()> emitError,
                     mlir::Type pointee) {



More information about the cfe-commits mailing list