已开启
[MLIR][LLVM] --llvm-legalize-float8-types 生成非法 IR:extractelement 未列入改写白名单、containsFloat8Type 不穿透 !llvm.array/!llvm.struct 聚合类型(合法输入被拒) #129
cactusBalll创建于 6 天前
6 天前 将 alexanderbill、li-yancheng、cf-zhao、eastb233、wangqiang95、kuenking111_admin、SegFault、wd-gitcode、chenzheng1030、gcw_LWQavIsb 设为负责人
6 天前 将 alexanderbill、li-yancheng、cf-zhao、eastb233、wangqiang95、kuenking111_admin、SegFault、wd-gitcode、chenzheng1030、gcw_LWQavIsb 设为负责人
6 天前 添加了label:sig/Compiler
openeuler-ci-bot
6 天前 评论:
6 天前 评论:
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 .


【缺陷描述】:请补充详细的缺陷问题现象描述
缺陷组件:MLIR LLVMIR dialect(LegalizeFloat8Types.cpp)
缺陷类型:生成非法 IR / 合法输入被拒(pass 硬失败,exit 1)
根因:类型替换按 op 白名单逐个应用,op 集合与类型集合均不完整,导致同一值的生产者与消费者类型不一致(i8 vs f8):
LLVM::ExtractElementOp未列入 isSafeOp 白名单(与 insertelement/shufflevector 同属"向量打包 op"类别);LLVM::StoreOp也未列入containsFloat8Type不递归进入 !llvm.array/!llvm.struct 聚合类型缺陷引入提交:
一、缺陷信息
mlir-opt --llvm-legalize-float8-types在两类完全合法的 LLVM dialect 输入上生成无法通过 verifier 的 IR,pass 以 exit 1 失败:llvm.insertelement在"安全 op"白名单内,其结果vector<4xf8E4M3FN>被改写为vector<4xi8>(LegalizeFloat8Types.cpp:159-168);但消费方llvm.extractelement不在白名单(仅 LoadOp/MaskedLoadOp/GEPOp/UndefOp/InsertElementOp/ShuffleVectorOp/BitcastOp,LegalizeFloat8Types.cpp:118-121),结果仍为 f8E4M3FN——操作数已是 i8 向量而结果是 f8 标量,'llvm.extractelement' op failed to verify that result type matches vector element typecontainsFloat8Type(LegalizeFloat8Types.cpp:48-61)只检查 VectorType/LLVMFixedVectorType/LLVMScalableVectorType,不穿透!llvm.array/!llvm.struct;load 结果被合法化 f8→i8,但!llvm.array<4 x f8E4M3FN>从未被改写,llvm.insertvalue %i8val, %arr报Type mismatch: cannot insert 'i8' into '!llvm.array<4 x f8E4M3FN>'【缺陷所属的os版本】
Ubuntu 22.04.3 LTS 缺陷位于编译器/MLIR 工具链本身,与操作系统版本无关。
【内核版本】
【缺陷所属软件及版本号】
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
【问题复现步骤】
执行
build/bin/mlir-opt repro.mlir --llvm-legalize-float8-types,输出
【实际结果】
【期望结果】
【其他相关附件信息】
【缺陷详情及分析指导参考链接】