[llvm-branch-commits] [mlir] a7eab64 - [mlir] Change ABI breaking use of NDEBUG to LLVM_ENABLE_ABI_BREAKING_CHECKS

Markus Böck via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Aug 3 00:15:37 PDT 2021


Author: Markus Böck
Date: 2021-08-03T09:14:57+02:00
New Revision: a7eab64b7c45d40154ec6f04d3a1f38b13dacfab

URL: https://github.com/llvm/llvm-project/commit/a7eab64b7c45d40154ec6f04d3a1f38b13dacfab
DIFF: https://github.com/llvm/llvm-project/commit/a7eab64b7c45d40154ec6f04d3a1f38b13dacfab.diff

LOG: [mlir] Change ABI breaking use of NDEBUG to LLVM_ENABLE_ABI_BREAKING_CHECKS

The `DataLayout` class currently contains the member `layoutStack` which is hidden behind a preprocessor region dependant on the NDEBUG macro. Code wise this makes a lot of sense, as the `layoutStack` is used for extra assertions that users will want when compiling a debug build.
It however has the uncomfortable consequence of leading to a different ABI in Debug and Release builds. This I think is a bit annoying for downstream projects and others as they may want to build against a stable Release of MLIR in Release mode, but be able to debug their own project depending on MLIR.

This patch changes the related uses of NDEBUG to LLVM_ENABLE_ABI_BREAKING_CHECKS. As the macro is computed at configure time of LLVM, it may not change based on compiler settings of a downstream projects like NDEBUG would.

Differential Revision: https://reviews.llvm.org/D107227

(cherry picked from commit 97335ad13fd4f231a75163a1e5c232aed5efe921)

Added: 
    

Modified: 
    mlir/include/mlir/Interfaces/DataLayoutInterfaces.h
    mlir/lib/Interfaces/DataLayoutInterfaces.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Interfaces/DataLayoutInterfaces.h b/mlir/include/mlir/Interfaces/DataLayoutInterfaces.h
index 0633eb341f11e..84fee54086539 100644
--- a/mlir/include/mlir/Interfaces/DataLayoutInterfaces.h
+++ b/mlir/include/mlir/Interfaces/DataLayoutInterfaces.h
@@ -163,7 +163,7 @@ class DataLayout {
   /// Combined layout spec at the given scope.
   const DataLayoutSpecInterface originalLayout;
 
-#ifndef NDEBUG
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
   /// List of enclosing layout specs.
   SmallVector<DataLayoutSpecInterface, 2> layoutStack;
 #endif

diff  --git a/mlir/lib/Interfaces/DataLayoutInterfaces.cpp b/mlir/lib/Interfaces/DataLayoutInterfaces.cpp
index 6244ac13ead95..5a63b287f5f41 100644
--- a/mlir/lib/Interfaces/DataLayoutInterfaces.cpp
+++ b/mlir/lib/Interfaces/DataLayoutInterfaces.cpp
@@ -269,7 +269,7 @@ mlir::DataLayout::DataLayout() : DataLayout(ModuleOp()) {}
 
 mlir::DataLayout::DataLayout(DataLayoutOpInterface op)
     : originalLayout(getCombinedDataLayout(op)), scope(op) {
-#ifndef NDEBUG
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
   checkMissingLayout(originalLayout, op);
   collectParentLayouts(op, layoutStack);
 #endif
@@ -277,7 +277,7 @@ mlir::DataLayout::DataLayout(DataLayoutOpInterface op)
 
 mlir::DataLayout::DataLayout(ModuleOp op)
     : originalLayout(getCombinedDataLayout(op)), scope(op) {
-#ifndef NDEBUG
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
   checkMissingLayout(originalLayout, op);
   collectParentLayouts(op, layoutStack);
 #endif
@@ -297,7 +297,7 @@ mlir::DataLayout mlir::DataLayout::closest(Operation *op) {
 }
 
 void mlir::DataLayout::checkValid() const {
-#ifndef NDEBUG
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
   SmallVector<DataLayoutSpecInterface> specs;
   collectParentLayouts(scope, specs);
   assert(specs.size() == layoutStack.size() &&


        


More information about the llvm-branch-commits mailing list