[Mlir-commits] [mlir] [mlir] Make single value `ValueRange`s memory safer (PR #121996)

Markus Böck llvmlistbot at llvm.org
Wed Jan 15 13:22:15 PST 2025


zero9178 wrote:

> The change seems to cause some assert failed.
> ```
> llvm/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:172:17: error: static assertion failed due to requirement '3U <= PointerUnionUIntTraits<const mlir::Value *, const mlir::Type *, mlir::OpOperand *, mlir::detail::OpResultImpl *, mlir::Type>::NumLowBitsAvailable': PointerIntPair with integer size too large for pointer
>   172 |   static_assert(IntBits <= PtrTraits::NumLowBitsAvailable,
>       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> llvm/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:111:13: note: in instantiation of template class 'llvm::PointerIntPairInfo<void *, 3, llvm::pointer_union_detail::PointerUnionUIntTraits<const mlir::Value *, const mlir::Type *, mlir::OpOperand *, mlir::detail::OpResultImpl *, mlir::Type>>' requested here
>   111 |     Value = Info::updateInt(Info::updatePointer(0, PtrVal),
>       |             ^
> llvm/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:89:5: note: in instantiation of member function 'llvm::PointerIntPair<void *, 3, int, llvm::pointer_union_detail::PointerUnionUIntTraits<const mlir::Value *, const mlir::Type *, mlir::OpOperand *, mlir::detail::OpResultImpl *, mlir::Type>>::setPointerAndInt' requested here
>    89 |     setPointerAndInt(PtrVal, IntVal);
>       |     ^
> llvm/llvm-project/llvm/include/llvm/ADT/PointerUnion.h:77:16: note: in instantiation of member function 'llvm::PointerIntPair<void *, 3, int, llvm::pointer_union_detail::PointerUnionUIntTraits<const mlir::Value *, const mlir::Type *, mlir::OpOperand *, mlir::detail::OpResultImpl *, mlir::Type>>::PointerIntPair' requested here
>    77 |         : Base(ValTy(const_cast<void *>(
>       |                ^
> llvm/llvm-project/mlir/include/mlir/IR/TypeRange.h:49:36: note: in instantiation of member function 'llvm::pointer_union_detail::PointerUnionMembers<llvm::PointerUnion<const mlir::Value *, const mlir::Type *, mlir::OpOperand *, mlir::detail::OpResultImpl *, mlir::Type>, llvm::PointerIntPair<void *, 3, int, llvm::pointer_union_detail::PointerUnionUIntTraits<const mlir::Value *, const mlir::Type *, mlir::OpOperand *, mlir::detail::OpResultImpl *, mlir::Type>>, 4, mlir::Type>::PointerUnionMembers' requested here
>    49 |   TypeRange(Type type) : TypeRange(type, /*count=*/1) {}
>       |                                    ^
> llvm/llvm-project/llvm/include/llvm/ADT/PointerIntPair.h:172:25: note: expression evaluates to '3 <= 2'
>   172 |   static_assert(IntBits <= PtrTraits::NumLowBitsAvailable,
>       |                 ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 1 error generated.
> ```

Thanks for the notification! Could you share more details about your C++ compiler and the environment you're compiling for? I thought the change would be safe for 32-bit due to `alignas` but I was probably wrong!

Currently AFK but feel free to revert in the meantime if this blocks you in any way 

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


More information about the Mlir-commits mailing list