Issue 182999
Summary [MLIR] Crash in VectorType creation during XeGPU --xegpu-wg-to-sg-distribute distribution pass
Labels mlir
Assignees
Reporter kitty-1998
    A crash occurs when processing this MLIR program through the XeGPU `--xegpu-wg-to-sg-distribute` pass. The crash happens during type conversion when `mlir::VectorType::get` is called.

```llvm
module {
  module {
 func.func @genVoteTestPattern(%arg0: tensor<?xi32>, %arg1: index) -> tensor<?xi32> {
      %c0 = arith.constant 0 : index
      %c1 = arith.constant 1 : index
      %init = tensor.empty(%arg1) : tensor<?xi32>
 
      %result = scf.for %i = %c0 to %arg1 step %c1 
 iter_args(%acc = %init) -> (tensor<?xi32>) {
        %mod = arith.remui %i, %c1 : index
        %is_odd = arith.cmpi eq, %mod, %c0 : index
        %val = arith.select %is_odd, %i, %c0 : index
        %val_i32 = arith.index_cast %val : index to i32
        %updated = tensor.insert %val_i32 into %acc[%i] : tensor<?xi32>
        scf.yield %updated : tensor<?xi32>
      }
 
      %extracted = tensor.extract %result[%c0] : tensor<?xi32>
      %neg = arith.xori %extracted, %extracted : i32
      %final = tensor.insert %neg into %result[%arg1] : tensor<?xi32>
      return %final : tensor<?xi32>
 }
  }
}
```
Version: 7dbfc2bd0078b36e4f9ed14dd25c4d8e97b3ae77

#### Stack Trace
```bash
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.      Program arguments: mlir-opt vote_intrinsics.mlir --convert-gpu-to-nvvm --xegpu-wg-to-sg-distribute
 #0 0x00005a143cabe1fd llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /llvm/lib/Support/Unix/Signals.inc:880:11
 #1 0x00005a143cabe72b PrintStackTraceSignalHandler(void*) /llvm/lib/Support/Unix/Signals.inc:962:1
 #2 0x00005a143cabc5c4 llvm::sys::RunSignalHandlers() /llvm/lib/Support/Signals.cpp:108:5
 #3 0x00005a143cabeec9 SignalHandler(int, siginfo_t*, void*) /llvm/lib/Support/Unix/Signals.inc:448:38
 #4 0x00007dc50f445330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #5 0x00007dc50f49eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #6 0x00007dc50f49eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #7 0x00007dc50f49eb2c pthread_kill ./nptl/pthread_kill.c:89:10
 #8 0x00007dc50f44527e raise ./signal/../sysdeps/posix/raise.c:27:6
 #9 0x00007dc50f4288ff abort ./stdlib/abort.c:81:7
#10 0x00007dc50f42881b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#11 0x00007dc50f43b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#12 0x00005a144b563f93 mlir::VectorType mlir::detail::StorageUserBase<mlir::VectorType, mlir::Type, mlir::detail::VectorTypeStorage, mlir::detail::TypeUniquer, mlir::ShapedType::Trait, mlir::ValueSemantics>::get<llvm::ArrayRef<long>&, mlir::Type&, llvm::ArrayRef<bool>&>(mlir::MLIRContext*, llvm::ArrayRef<long>&, mlir::Type&, llvm::ArrayRef<bool>&) /mlir/include/mlir/IR/StorageUniquerSupport.h:179:5
#13 0x00005a144b55f188 mlir::VectorType::get(llvm::ArrayRef<long>, mlir::Type, llvm::ArrayRef<bool>) /build_all/tools/mlir/include/mlir/IR/BuiltinTypes.cpp.inc:589:10
#14 0x00005a1444da9977 (anonymous namespace)::XeGPUWgToSgDistributePass::runOnOperation()::$_14::operator()(mlir::RankedTensorType, llvm::SmallVectorImpl<mlir::Type>&) const /mlir/lib/Dialect/XeGPU/Transforms/XeGPUWgToSgDistribute.cpp:1762:24
#15 0x00005a1444da9815 std::enable_if<std::is_invocable_v<(anonymous namespace)::XeGPUWgToSgDistributePass::runOnOperation()::$_14, mlir::RankedTensorType, llvm::SmallVectorImpl<mlir::Type>&> && std::is_base_of_v<mlir::Type, mlir::RankedTensorType>, std::function<std::optional<llvm::LogicalResult> (llvm::PointerUnion<mlir::Type, mlir::Value>, llvm::SmallVectorImpl<mlir::Type>&)>>::type mlir::TypeConverter::wrapCallback<mlir::RankedTensorType, (anonymous namespace)::XeGPUWgToSgDistributePass::runOnOperation()::$_14>((anonymous namespace)::XeGPUWgToSgDistributePass::runOnOperation()::$_14&&) const::'lambda'(llvm::PointerUnion<mlir::Type, mlir::Value>, llvm::SmallVectorImpl<mlir::Type>&)::operator()(llvm::PointerUnion<mlir::Type, mlir::Value>, llvm::SmallVectorImpl<mlir::Type>&) const /mlir/include/mlir/Transforms/DialectConversion.h:430:14
#16 0x00005a1444da9720 mlir::RankedTensorType std::__invoke_impl<std::optional<llvm::LogicalResult>, std::enable_if<std::is_invocable_v<(anonymous namespace)::XeGPUWgToSgDistributePass::runOnOperation()::$_14, mlir::RankedTensorType, llvm::SmallVectorImpl<mlir::Type>&> && std::is_base_of_v<mlir::Type, mlir::RankedTensorType>, std::function<std::optional<llvm::LogicalResult> (llvm::PointerUnion<mlir::Type, mlir::Value>, llvm::SmallVectorImpl<mlir::Type>&)>>::type mlir::TypeConverter::wrapCallback<mlir::RankedTensorType, (anonymous namespace)::XeGPUWgToSgDistributePass::runOnOperation()::$_14>((anonymous namespace)::XeGPUWgToSgDistributePass::runOnOperation()::$_14&&) const::'lambda'(llvm::PointerUnion<mlir::Type, mlir::Value>, llvm::SmallVectorImpl<mlir::Type>&)&, llvm::PointerUnion<mlir::Type, mlir::Value>, llvm::SmallVectorImpl<mlir::Type>&>(std::__invoke_other, (anonymous namespace)::XeGPUWgToSgDistributePass::runOnOperation()::$_14&&, llvm::PointerUnion<mlir::Type, mlir::Value>&&, llvm::SmallVectorImpl<mlir::Type>&) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/invoke.h:61:14
#17 0x00005a1444da96a5 std::enable_if<is_invocable_r_v<mlir::RankedTensorType, (anonymous namespace)::XeGPUWgToSgDistributePass::runOnOperation()::$_14, llvm::PointerUnion<mlir::Type, mlir::Value>, llvm::SmallVectorImpl<mlir::Type>&>, mlir::RankedTensorType>::type std::__invoke_r<std::optional<llvm::LogicalResult>, std::enable_if<std::is_invocable_v<(anonymous namespace)::XeGPUWgToSgDistributePass::runOnOperation()::$_14, mlir::RankedTensorType, llvm::SmallVectorImpl<mlir::Type>&> && std::is_base_of_v<mlir::Type, mlir::RankedTensorType>, std::function<std::optional<llvm::LogicalResult> (llvm::PointerUnion<mlir::Type, mlir::Value>, llvm::SmallVectorImpl<mlir::Type>&)>>::type mlir::TypeConverter::wrapCallback<mlir::RankedTensorType, (anonymous namespace)::XeGPUWgToSgDistributePass::runOnOperation()::$_14>((anonymous namespace)::XeGPUWgToSgDistributePass::runOnOperation()::$_14&&) const::'lambda'(llvm::PointerUnion<mlir::Type, mlir::Value>, llvm::SmallVectorImpl<mlir::Type>&)&, llvm::PointerUnion<mlir::Type, mlir::Value>, llvm::SmallVectorImpl<mlir::Type>&>((anonymous namespace)::XeGPUWgToSgDistributePass::runOnOperation()::$_14&&, llvm::PointerUnion<mlir::Type, mlir::Value>&&, llvm::SmallVectorImpl<mlir::Type>&) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/invoke.h:114:9
#18 0x00005a1444da95bd std::_Function_handler<std::optional<llvm::LogicalResult> (llvm::PointerUnion<mlir::Type, mlir::Value>, llvm::SmallVectorImpl<mlir::Type>&), std::enable_if<std::is_invocable_v<(anonymous namespace)::XeGPUWgToSgDistributePass::runOnOperation()::$_14, mlir::RankedTensorType, llvm::SmallVectorImpl<mlir::Type>&> && std::is_base_of_v<mlir::Type, mlir::RankedTensorType>, std::function<std::optional<llvm::LogicalResult> (llvm::PointerUnion<mlir::Type, mlir::Value>, llvm::SmallVectorImpl<mlir::Type>&)>>::type mlir::TypeConverter::wrapCallback<mlir::RankedTensorType, (anonymous namespace)::XeGPUWgToSgDistributePass::runOnOperation()::$_14>((anonymous namespace)::XeGPUWgToSgDistributePass::runOnOperation()::$_14&&) const::'lambda'(llvm::PointerUnion<mlir::Type, mlir::Value>, llvm::SmallVectorImpl<mlir::Type>&)>::_M_invoke(std::_Any_data const&, llvm::PointerUnion<mlir::Type, mlir::Value>&&, llvm::SmallVectorImpl<mlir::Type>&) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_function.h:290:9
#19 0x00005a144b002cee std::function<std::optional<llvm::LogicalResult> (llvm::PointerUnion<mlir::Type, mlir::Value>, llvm::SmallVectorImpl<mlir::Type>&)>::operator()(llvm::PointerUnion<mlir::Type, mlir::Value>, llvm::SmallVectorImpl<mlir::Type>&) const /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_function.h:591:9
#20 0x00005a144afe0e9a mlir::TypeConverter::convertTypeImpl(llvm::PointerUnion<mlir::Type, mlir::Value>, llvm::SmallVectorImpl<mlir::Type>&) const /mlir/lib/Transforms/Utils/DialectConversion.cpp:3584:43
#21 0x00005a144afd8b22 mlir::TypeConverter::convertType(mlir::Value, llvm::SmallVectorImpl<mlir::Type>&) const /mlir/lib/Transforms/Utils/DialectConversion.cpp:3617:10
#22 0x00005a144afe12ea mlir::TypeConverter::convertType(mlir::Value) const /mlir/lib/Transforms/Utils/DialectConversion.cpp:3633:14
#23 0x00005a144afe14a5 mlir::TypeConverter::isLegal(mlir::Value) const /mlir/lib/Transforms/Utils/DialectConversion.cpp:3663:10
#24 0x00005a1447779648 mlir::TypeConverter::isLegal(mlir::ValueRange) const::'lambda'(mlir::Value)::operator()(mlir::Value) const /mlir/include/mlir/Transforms/DialectConversion.h:315:54
#25 0x00005a1447779616 bool __gnu_cxx::__ops::_Iter_negate<mlir::TypeConverter::isLegal(mlir::ValueRange) const::'lambda'(mlir::Value)>::operator()<llvm::detail::indexed_accessor_range_base<mlir::ValueRange, llvm::PointerUnion<mlir::Value const*, mlir::OpOperand*, mlir::detail::OpResultImpl*>, mlir::Value, mlir::Value, mlir::Value>::iterator>(llvm::detail::indexed_accessor_range_base<mlir::ValueRange, llvm::PointerUnion<mlir::Value const*, mlir::OpOperand*, mlir::detail::OpResultImpl*>, mlir::Value, mlir::Value, mlir::Value>::iterator) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/predefined_ops.h:395:11
#26 0x00005a144777955e llvm::detail::indexed_accessor_range_base<mlir::ValueRange, llvm::PointerUnion<mlir::Value const*, mlir::OpOperand*, mlir::detail::OpResultImpl*>, mlir::Value, mlir::Value, mlir::Value>::iterator std::__find_if<llvm::detail::indexed_accessor_range_base<mlir::ValueRange, llvm::PointerUnion<mlir::Value const*, mlir::OpOperand*, mlir::detail::OpResultImpl*>, mlir::Value, mlir::Value, mlir::Value>::iterator, __gnu_cxx::__ops::_Iter_negate<mlir::TypeConverter::isLegal(mlir::ValueRange) const::'lambda'(mlir::Value)>>(llvm::detail::indexed_accessor_range_base<mlir::ValueRange, llvm::PointerUnion<mlir::Value const*, mlir::OpOperand*, mlir::detail::OpResultImpl*>, mlir::Value, mlir::Value, mlir::Value>::iterator, llvm::detail::indexed_accessor_range_base<mlir::ValueRange, llvm::PointerUnion<mlir::Value const*, mlir::OpOperand*, mlir::detail::OpResultImpl*>, mlir::Value, mlir::Value, mlir::Value>::iterator, __gnu_cxx::__ops::_Iter_negate<mlir::TypeConverter::isLegal(mlir::ValueRange) const::'lambda'(mlir::Value)>, std::random_access_iterator_tag) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_algobase.h:2102:8
#27 0x00005a14477792a5 llvm::detail::indexed_accessor_range_base<mlir::ValueRange, llvm::PointerUnion<mlir::Value const*, mlir::OpOperand*, mlir::detail::OpResultImpl*>, mlir::Value, mlir::Value, mlir::Value>::iterator std::__find_if_not<llvm::detail::indexed_accessor_range_base<mlir::ValueRange, llvm::PointerUnion<mlir::Value const*, mlir::OpOperand*, mlir::detail::OpResultImpl*>, mlir::Value, mlir::Value, mlir::Value>::iterator, __gnu_cxx::__ops::_Iter_pred<mlir::TypeConverter::isLegal(mlir::ValueRange) const::'lambda'(mlir::Value)>>(llvm::detail::indexed_accessor_range_base<mlir::ValueRange, llvm::PointerUnion<mlir::Value const*, mlir::OpOperand*, mlir::detail::OpResultImpl*>, mlir::Value, mlir::Value, mlir::Value>::iterator, llvm::detail::indexed_accessor_range_base<mlir::ValueRange, llvm::PointerUnion<mlir::Value const*, mlir::OpOperand*, mlir::detail::OpResultImpl*>, mlir::Value, mlir::Value, mlir::Value>::iterator, __gnu_cxx::__ops::_Iter_pred<mlir::TypeConverter::isLegal(mlir::ValueRange) const::'lambda'(mlir::Value)>) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_algo.h:112:14
#28 0x00005a144777922a llvm::detail::indexed_accessor_range_base<mlir::ValueRange, llvm::PointerUnion<mlir::Value const*, mlir::OpOperand*, mlir::detail::OpResultImpl*>, mlir::Value, mlir::Value, mlir::Value>::iterator std::find_if_not<llvm::detail::indexed_accessor_range_base<mlir::ValueRange, llvm::PointerUnion<mlir::Value const*, mlir::OpOperand*, mlir::detail::OpResultImpl*>, mlir::Value, mlir::Value, mlir::Value>::iterator, mlir::TypeConverter::isLegal(mlir::ValueRange) const::'lambda'(mlir::Value)>(llvm::detail::indexed_accessor_range_base<mlir::ValueRange, llvm::PointerUnion<mlir::Value const*, mlir::OpOperand*, mlir::detail::OpResultImpl*>, mlir::Value, mlir::Value, mlir::Value>::iterator, llvm::detail::indexed_accessor_range_base<mlir::ValueRange, llvm::PointerUnion<mlir::Value const*, mlir::OpOperand*, mlir::detail::OpResultImpl*>, mlir::Value, mlir::Value, mlir::Value>::iterator, mlir::TypeConverter::isLegal(mlir::ValueRange) const::'lambda'(mlir::Value)) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_algo.h:519:14
#29 0x00005a14477791ad bool std::all_of<llvm::detail::indexed_accessor_range_base<mlir::ValueRange, llvm::PointerUnion<mlir::Value const*, mlir::OpOperand*, mlir::detail::OpResultImpl*>, mlir::Value, mlir::Value, mlir::Value>::iterator, mlir::TypeConverter::isLegal(mlir::ValueRange) const::'lambda'(mlir::Value)>(llvm::detail::indexed_accessor_range_base<mlir::ValueRange, llvm::PointerUnion<mlir::Value const*, mlir::OpOperand*, mlir::detail::OpResultImpl*>, mlir::Value, mlir::Value, mlir::Value>::iterator, llvm::detail::indexed_accessor_range_base<mlir::ValueRange, llvm::PointerUnion<mlir::Value const*, mlir::OpOperand*, mlir::detail::OpResultImpl*>, mlir::Value, mlir::Value, mlir::Value>::iterator, mlir::TypeConverter::isLegal(mlir::ValueRange) const::'lambda'(mlir::Value)) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_algo.h:459:24
#30 0x00005a1447779143 bool llvm::all_of<mlir::ValueRange&, mlir::TypeConverter::isLegal(mlir::ValueRange) const::'lambda'(mlir::Value)>(mlir::ValueRange&, mlir::TypeConverter::isLegal(mlir::ValueRange) const::'lambda'(mlir::Value)) /llvm/include/llvm/ADT/STLExtras.h:1740:3
#31 0x00005a14477790d9 mlir::TypeConverter::isLegal(mlir::ValueRange) const /mlir/include/mlir/Transforms/DialectConversion.h:315:5
#32 0x00005a144831292e mlir::scf::populateSCFStructuralTypeConversionTarget(mlir::TypeConverter const&, mlir::ConversionTarget&)::$_0::operator()(mlir::Operation*) const /mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp:255:28
#33 0x00005a14483128d0 bool std::__invoke_impl<bool, mlir::scf::populateSCFStructuralTypeConversionTarget(mlir::TypeConverter const&, mlir::ConversionTarget&)::$_0&, mlir::Operation*>(std::__invoke_other, mlir::scf::populateSCFStructuralTypeConversionTarget(mlir::TypeConverter const&, mlir::ConversionTarget&)::$_0&, mlir::Operation*&&) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/invoke.h:61:7
#34 0x00005a144831285d std::enable_if<is_invocable_r_v<std::optional<bool>, mlir::scf::populateSCFStructuralTypeConversionTarget(mlir::TypeConverter const&, mlir::ConversionTarget&)::$_0&, mlir::Operation*>, std::optional<bool>>::type std::__invoke_r<std::optional<bool>, mlir::scf::populateSCFStructuralTypeConversionTarget(mlir::TypeConverter const&, mlir::ConversionTarget&)::$_0&, mlir::Operation*><truncated>Please see the issue for the entire body.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to