已开启
[MLIR][Vector] SVE 浮点 vector.outerproduct 无累加器时以 null Value 构造 vector.scalable.insert(UBSan/崩溃,无 IR 输出) #134
cactusBalll创建于  2 天前
cactusBalll
2 天前 创建

【缺陷描述】:请补充详细的缺陷问题现象描述

合法的双操作数(无累加器)形式:

%0 = vector.outerproduct %a, %b : vector<2xf32>, vector<4xf32>

transform.apply_patterns.vector.lower_outerproduct enableSVE = true(或 --convert-vector-to-llvm="enable-arm-sve=true")lowering 时,OuterProductOpLowering 以 null Value 构造 vector::ScalableInsertOp——builder 解引用空指针:

mlir/include/mlir/IR/UseDefLists.h:98:22: runtime error: member access within null pointer
of type 'mlir::IRObjectWithUseList<mlir::OpOperand>'

mlir-opt 退出码 1、无 IR 输出(UBSan 确认 null 解引用)。fe4cb010 为整数类型修复了同类问题(跳过 fmla.lane 走 arith 路径),但浮点 SVE 路径在 acc == nullptr 时仍进入并使用未初始化的 r

一、缺陷信息

  • 缺陷组件:MLIR Vector dialect(LowerVectorContract.cpp,OuterProductOpLowering::matchAndRewrite
  • 缺陷类型:崩溃(null Value UB;断言构建下表现为空指针解引用/异常退出)
  • 根因:mlir/lib/Dialect/Vector/Transforms/LowerVectorContract.cpp:1256-1262:
    Value r = nullptr;
    if (acc)
      r = rewriter.create<vector::ExtractOp>(loc, acc, d);
    if (vectorTransformOptions.armSve && !isInt) {   // 浮点 + SVE
      ...
      r = rewriter.create<vector::ScalableInsertOp>(loc, r, udef, 0);  // acc 缺失时 r 为 null
    
    无累加器时 r 保持 null 却被传入 ScalableInsertOp builder(UseDefLists.h:98 解引用 Value::Impl)。通用(非 SVE)路径正确处理 acc==nullptr(createContractArithOp)

缺陷关联提交:

  • dda389ea5800883cc30de9b7f40d091e4a4383e4 "Add SVE lowering"(引入 SVE outerproduct 路径)
  • fe4cb010691d92331aa96e6fed88cf6d984d58fd "[MLIR][Vector] Fix OuterProductOpLowering: skip SVE fmla.lane for integer types"(修复整数路径,浮点路径的 null acc 未处理)
  • 3356bb977a37b12dcad52096f26e2fd147f00a18 "!407 [MLIR] Add Support for Triton3.2 + Triton-Shared"(合并保留)

【缺陷所属的os版本】

Ubuntu 22.04.3 LTS,缺陷位于编译器/MLIR 工具链本身,与操作系统版本无关。

【内核版本】

6.6.87.2-microsoft-standard-WSL2(uname -r)。缺陷与内核版本无关。

【缺陷所属软件及版本号】

LLVM 20.1.8

【环境信息】

编译选项:
CMAKE_BUILD_TYPE=RelWithDebInfo,LLVM_ENABLE_ASSERTIONS=ON,LLVM_ENABLE_PROJECTS="clang;mlir",LLVM_TARGETS_TO_BUILD="X86;AArch64"

COMMIT ID:35f464110c04e89bd0cab0e3fee4a70ec6ec2eb9

【问题复现步骤】

module attributes {transform.with_named_sequence} {
  transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {
      %f = transform.structured.match ops{["func.func"]} in %arg1
        : (!transform.any_op) -> !transform.any_op
      transform.apply_patterns to %f {
        transform.apply_patterns.vector.lower_outerproduct enableSVE = true
      } : !transform.any_op
    transform.yield
  }
}
func.func @outerproduct_noacc_f32(%arg0 : vector<2xf32>, %arg1 : vector<4xf32>) -> vector<2x4xf32> {
    %0 = vector.outerproduct %arg0, %arg1 : vector<2xf32>, vector<4xf32>
    return %0 : vector<2x4xf32>
}

执行mlir-opt test.mlir --transform-interpreter,若启用UBSan构建,则崩溃并打印空指针解引用错误。

【实际结果】

【期望结果】

【其他相关附件信息】

【缺陷详情及分析指导参考链接】

likedislike
openeuler-ci-botopeneuler-ci-bot成员
2 天前 将 alexanderbill、li-yancheng、cf-zhao、eastb233、wangqiang95、kuenking111_admin、SegFault、wd-gitcode、chenzheng1030、gcw_LWQavIsb 设为负责人
openeuler-ci-botopeneuler-ci-bot成员
2 天前 添加了label:sig/Compiler
openeuler-ci-bot
openeuler-ci-bot成员
2 天前 评论:

Welcome To openEuler Community

Hey @gcw_LWQavIsb , thanks for your contribution to the community.

Bot Usage Manual

I'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands. You can self-configure the PR merge rules for this repository. For more details, please refer to Here.

Contact Guide

If you have any questions, please contact the SIG: Compiler ,
and any of the maintainers: @SegFault, @alexanderbill, @cf-zhao, @chenzheng1030, @eastb233, @kuenking111_admin, @li-yancheng, @wangqiang95, @wd-gitcode ,
and any of the committers: @liyunfei33, @zhongyunde .

likedislike