)]}'
{
  "commit": "38afe0ad63d3d166671a4ed90da80e3a5b82a816",
  "tree": "b0e5944cbf537b88b33023a59b74638c33a3be9d",
  "parents": [
    "21a674843cd24adfdd5d5e7acb1e91ee644b45e4"
  ],
  "author": {
    "name": "pstarkcdpr",
    "email": "paul.stark@cdprojektred.com",
    "time": "Mon Jul 06 02:22:58 2026 -0700"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Mon Jul 06 11:22:58 2026 +0200"
  },
  "message": "Address crash in iree-reduce with complex tensors (#24674)\n\nSee issue https://github.com/iree-org/iree/issues/24673. Details are\nrepeated here.\n\n`iree-reduce` crashes in `reduceLinalgOnTensorsDelta` when it tries to\nreplace a `linalg` op that produces a **complex**-typed tensor. The\nstrategy builds a zero constant via `Builder::getZeroAttr(elementType)`,\nwhich returns a **null** attribute for `complex` (it only supports\nint/index/float). Creating an `arith.constant` from the null attribute\naborts the process.\n\nThe proposed fix simply does an early-out if the type is not int, float,\nor index instead of crashing.\n\nRepro:\n`interesting.sh`\n```bash\n#!/bin/bash\n# Interestingness oracle for iree-reduce.\n#\n# A reduced candidate is \"interesting\" (exit 0) only while it still contains the\n# complex-typed linalg.generic (identified by the complex.create in its body).\n# This keeps the reducer from deleting the op via an earlier strategy, so it\n# reaches reduceLinalgOnTensorsDelta with the complex op still present.\ngrep -q \"complex.create\" \"$1\"\n```\n\n`complex_repro.mlir`\n```\n// Minimal reproducer for the iree-reduce crash in reduceLinalgOnTensorsDelta.\n//\n// The linalg.generic writes a complex\u003cf32\u003e tensor. When the reducer decides to\n// replace this op with a linalg.fill of a zero constant, it calls\n// Builder::getZeroAttr(complex\u003cf32\u003e), which returns a null attribute. Building\n// an arith.constant from that null attribute crashes (\"Failed to infer result\n// type(s)\").\n//\n// The op survives the earlier reduction strategies because the interestingness\n// check (interesting.sh) requires \"complex.create\" to remain present, so the\n// reducer reaches reduceLinalgOnTensorsDelta with the complex op still in place.\nfunc.func @main(%arg0: tensor\u003c4xf32\u003e) -\u003e tensor\u003c4xcomplex\u003cf32\u003e\u003e {\n  %empty \u003d tensor.empty() : tensor\u003c4xcomplex\u003cf32\u003e\u003e\n  %0 \u003d linalg.generic {\n    indexing_maps \u003d [affine_map\u003c(d0) -\u003e (d0)\u003e, affine_map\u003c(d0) -\u003e (d0)\u003e],\n    iterator_types \u003d [\"parallel\"]\n  } ins(%arg0 : tensor\u003c4xf32\u003e) outs(%empty : tensor\u003c4xcomplex\u003cf32\u003e\u003e) {\n  ^bb0(%in: f32, %out: complex\u003cf32\u003e):\n    %c \u003d complex.create %in, %in : complex\u003cf32\u003e\n    linalg.yield %c : complex\u003cf32\u003e\n  } -\u003e tensor\u003c4xcomplex\u003cf32\u003e\u003e\n  return %0 : tensor\u003c4xcomplex\u003cf32\u003e\u003e\n}\n```\n\nRun using:\n```bash\nchmod +x interesting.sh\niree-reduce ./interesting.sh ./complex_repro.mlir -o reduced.mlir\n```\n\nCrashes with:\n```\nLLVM ERROR: Failed to infer result type(s):\n\"arith.constant\"(...) {} : () -\u003e ( ??? )\nPlease report issues to https://github.com/iree-org/iree/issues and include the crash backtrace.\nStack dump:\n0.      Program arguments: ../../fix-undef-global-hoist/iree-compiler/tools/iree-reduce ./interesting.sh ./complex_repro.mlir -o reduced.mlir\n #0 0x00007aa82ee7cf5b llvm::sys::PrintStackTrace(llvm::raw_ostream\u0026, int) fix-undef-global-hoist/iree/third_party/llvm-project/llvm/lib/Support/Unix/Signals.inc:881:13\n #1 0x00007aa82ee7ab83 llvm::sys::RunSignalHandlers() fix-undef-global-hoist/iree/third_party/llvm-project/llvm/lib/Support/Signals.cpp:109:18\n #2 0x00007aa82ee7de71 SignalHandler(int, siginfo_t*, void*) fix-undef-global-hoist/iree/third_party/llvm-project/llvm/lib/Support/Unix/Signals.inc:448:38\n #3 0x00007aa828e45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)\n #4 0x00007aa828e9eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\n #5 0x00007aa828e9eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10\n #6 0x00007aa828e9eb2c pthread_kill ./nptl/pthread_kill.c:89:10\n #7 0x00007aa828e4527e raise ./signal/../sysdeps/posix/raise.c:27:6\n #8 0x00007aa828e288ff abort ./stdlib/abort.c:81:7\n #9 0x00007aa82ee0850b llvm::report_fatal_error(llvm::Twine const\u0026, bool) fix-undef-global-hoist/iree/third_party/llvm-project/llvm/lib/Support/ErrorHandling.cpp:137:5\n#10 0x00007aa82ee0858e (fix-undef-global-hoist/iree-compiler/lib/libIREECompiler.so+0x580858e)\n#11 0x00007aa837dabc21 (fix-undef-global-hoist/iree-compiler/lib/libIREECompiler.so+0xe7abc21)\n#12 0x00007aa834c50cc1 llvm::SmallVectorTemplateCommon\u003cmlir::Type, void\u003e::begin() fix-undef-global-hoist/iree/third_party/llvm-project/llvm/include/llvm/ADT/SmallVector.h:276:45\n#13 0x00007aa834c50cc1 llvm::SmallVectorTemplateCommon\u003cmlir::Type, void\u003e::end() fix-undef-global-hoist/iree/third_party/llvm-project/llvm/include/llvm/ADT/SmallVector.h:278:27\n#14 0x00007aa834c50cc1 llvm::SmallVector\u003cmlir::Type, 2u\u003e::~SmallVector() fix-undef-global-hoist/iree/third_party/llvm-project/llvm/include/llvm/ADT/SmallVector.h:1242:46\n#15 0x00007aa834c50cc1 mlir::arith::ConstantOp::build(mlir::OpBuilder\u0026, mlir::OperationState\u0026, mlir::TypedAttr) fix-undef-global-hoist/iree-compiler/llvm-project/tools/mlir/include/mlir/Dialect/Arith/IR/ArithOps.cpp.inc:4379:1\n#16 0x00007aa834c131be mlir::arith::ConstantOp::create(mlir::OpBuilder\u0026, mlir::Location, mlir::TypedAttr) fix-undef-global-hoist/iree-compiler/llvm-project/tools/mlir/include/mlir/Dialect/Arith/IR/ArithOps.cpp.inc:4384:55\n#17 0x00007aa8337db6af mlir::Operation::getInlineOpResult(unsigned int) fix-undef-global-hoist/iree/third_party/llvm-project/mlir/include/mlir/IR/Operation.h:1035:61\n#18 0x00007aa8337db6af mlir::Operation::getOpResultImpl(unsigned int) fix-undef-global-hoist/iree/third_party/llvm-project/mlir/include/mlir/IR/Operation.h:1045:14\n#19 0x00007aa8337db6af mlir::Operation::getResult(unsigned int) fix-undef-global-hoist/iree/third_party/llvm-project/mlir/include/mlir/IR/Operation.h:432:54\n#20 0x00007aa8337db6af mlir::OpTrait::OneTypedResult\u003cmlir::Type\u003e::Impl\u003cmlir::arith::ConstantOp\u003e::getResult() fix-undef-global-hoist/iree/third_party/llvm-project/mlir/include/mlir/IR/OpDefinition.h:708:33\n#21 0x00007aa8337db6af mlir::OpTrait::OneTypedResult\u003cmlir::Type\u003e::Impl\u003cmlir::arith::ConstantOp\u003e::operator mlir::Value() fix-undef-global-hoist/iree/third_party/llvm-project/mlir/include/mlir/IR/OpDefinition.h:713:54\n#22 0x00007aa8337db6af mlir::iree_compiler::Reducer::reduceLinalgOnTensorsDelta(mlir::iree_compiler::Reducer::ChunkManager\u0026, mlir::iree_compiler::Reducer::WorkItem\u0026) fix-undef-global-hoist/iree/compiler/src/iree/compiler/Reducer/Strategies/ReduceLinalgOnTensorsDelta.cpp:114:18\n#23 0x00007aa834d464dd mlir::iree_compiler::Reducer::Delta::checkChunk(mlir::iree_compiler::Reducer::Chunk, llvm::function_ref\u003cvoid (mlir::iree_compiler::Reducer::ChunkManager\u0026, mlir::iree_compiler::Reducer::WorkItem\u0026)\u003e, llvm::ArrayRef\u003cmlir::iree_compiler::Reducer::Chunk\u003e, llvm::DenseSet\u003cmlir::iree_compiler::Reducer::Chunk, llvm::DenseMapInfo\u003cmlir::iree_compiler::Reducer::Chunk, void\u003e\u003e\u0026) fix-undef-global-hoist/iree/compiler/src/iree/compiler/Reducer/Framework/Delta.cpp:39:8\n#24 0x00007aa834d46aa7 llvm::LogicalResult::failed() const fix-undef-global-hoist/iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:43:43\n#25 0x00007aa834d46aa7 llvm::failed(llvm::LogicalResult) fix-undef-global-hoist/iree/third_party/llvm-project/llvm/include/llvm/Support/LogicalResult.h:71:58\n#26 0x00007aa834d46aa7 mlir::iree_compiler::Reducer::Delta::runDeltaPass(llvm::function_ref\u003cvoid (mlir::iree_compiler::Reducer::ChunkManager\u0026, mlir::iree_compiler::Reducer::WorkItem\u0026)\u003e, llvm::StringRef) fix-undef-global-hoist/iree/compiler/src/iree/compiler/Reducer/Framework/Delta.cpp:105:11\n#27 0x00007aa82f5d68ea mlir::iree_compiler::Reducer::ireeRunReducingStrategies(mlir::OwningOpRef\u003cmlir::Operation*\u003e, mlir::iree_compiler::Reducer::ReducerConfig\u0026) fix-undef-global-hoist/iree/compiler/src/iree/compiler/Reducer/iree_reduce_lib.cc:39:9\n#28 0x00007aa82edba149 ireeReduceMainFromCL(int, char**, mlir::MLIRContext\u0026) fix-undef-global-hoist/iree/compiler/src/iree/compiler/API/Internal/IREEReduceToolEntryPoint.cpp:102:26\n#29 0x00007aa82edba149 ireeReduceRunMain fix-undef-global-hoist/iree/compiler/src/iree/compiler/API/Internal/IREEReduceToolEntryPoint.cpp:134:7\n#30 0x00007aa828e2a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\n#31 0x00007aa828e2a28b call_init ./csu/../csu/libc-start.c:128:20\n#32 0x00007aa828e2a28b __libc_start_main ./csu/../csu/libc-start.c:347:5\n#33 0x00005a84cb2e26e5 _start (../../fix-undef-global-hoist/iree-compiler/tools/iree-reduce+0x16e5)\n```\n\nSigned-off-by: Paul Stark \u003cpaul.stark@cdprojektred.com\u003e\nCo-authored-by: Claude Opus 4.8 (1M context) \u003cnoreply@anthropic.com\u003e",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "4d66462d37c5467a5386c1141d987e19fcf09cbd",
      "old_mode": 33188,
      "old_path": "compiler/src/iree/compiler/Reducer/Strategies/ReduceLinalgOnTensorsDelta.cpp",
      "new_id": "d427fac3f1907452920794414d89f391a1e503b0",
      "new_mode": 33188,
      "new_path": "compiler/src/iree/compiler/Reducer/Strategies/ReduceLinalgOnTensorsDelta.cpp"
    }
  ]
}
