Fix MLIR crash on 32 bits platforms
authorMehdi Amini <joker.eph@gmail.com>
Thu, 18 May 2023 04:53:05 +0000 (21:53 -0700)
committerMehdi Amini <joker.eph@gmail.com>
Thu, 18 May 2023 04:58:20 +0000 (21:58 -0700)
The properties size is compressed as a member of the Operation class
to assume a multiple of 8B is used for the storage. This matched the
natural alignment / padding on 64 bits platforms, however we need some
explicit padding on 32 bits platforms, llvm::TrailingObjects will
compress and misalign.

Fixes #62763

mlir/lib/IR/Operation.cpp

index 42b2c79..64cbeb6 100644 (file)
@@ -91,7 +91,7 @@ Operation *Operation::create(Location location, OperationName name,
   unsigned numSuccessors = successors.size();
   unsigned numOperands = operands.size();
   unsigned numResults = resultTypes.size();
-  int opPropertiesAllocSize = name.getOpPropertyByteSize();
+  int opPropertiesAllocSize = llvm::alignTo<8>(name.getOpPropertyByteSize());
 
   // If the operation is known to have no operands, don't allocate an operand
   // storage.