Skip to content

Commit a7eab64

Browse files
committed
[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 97335ad)
1 parent d6974c0 commit a7eab64

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

mlir/include/mlir/Interfaces/DataLayoutInterfaces.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class DataLayout {
163163
/// Combined layout spec at the given scope.
164164
const DataLayoutSpecInterface originalLayout;
165165

166-
#ifndef NDEBUG
166+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
167167
/// List of enclosing layout specs.
168168
SmallVector<DataLayoutSpecInterface, 2> layoutStack;
169169
#endif

mlir/lib/Interfaces/DataLayoutInterfaces.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,15 @@ mlir::DataLayout::DataLayout() : DataLayout(ModuleOp()) {}
269269

270270
mlir::DataLayout::DataLayout(DataLayoutOpInterface op)
271271
: originalLayout(getCombinedDataLayout(op)), scope(op) {
272-
#ifndef NDEBUG
272+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
273273
checkMissingLayout(originalLayout, op);
274274
collectParentLayouts(op, layoutStack);
275275
#endif
276276
}
277277

278278
mlir::DataLayout::DataLayout(ModuleOp op)
279279
: originalLayout(getCombinedDataLayout(op)), scope(op) {
280-
#ifndef NDEBUG
280+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
281281
checkMissingLayout(originalLayout, op);
282282
collectParentLayouts(op, layoutStack);
283283
#endif
@@ -297,7 +297,7 @@ mlir::DataLayout mlir::DataLayout::closest(Operation *op) {
297297
}
298298

299299
void mlir::DataLayout::checkValid() const {
300-
#ifndef NDEBUG
300+
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
301301
SmallVector<DataLayoutSpecInterface> specs;
302302
collectParentLayouts(scope, specs);
303303
assert(specs.size() == layoutStack.size() &&

0 commit comments

Comments
 (0)