Skip to content

update llvm and stablehlo #3232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/BuildOnLinuxOSX.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Firstly, install MLIR (as a part of LLVM-Project):
``` bash
git clone -n https://github.com/llvm/llvm-project.git
# Check out a specific branch that is known to work with ONNX-MLIR.
cd llvm-project && git checkout 7a33569510535f0b917a2e50f644bf57490aee24 && cd ..
cd llvm-project && git checkout f8cb7987c64dcffb72414a40560055cb717dbf74 && cd ..
```

[same-as-file]: <> (utils/build-mlir.sh)
Expand Down
2 changes: 1 addition & 1 deletion docs/BuildOnWindows.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Install MLIR (as a part of LLVM-Project):
```shell
git clone -n https://github.com/llvm/llvm-project.git
# Check out a specific branch that is known to work with ONNX-MLIR.
cd llvm-project && git checkout 7a33569510535f0b917a2e50f644bf57490aee24 && cd ..
cd llvm-project && git checkout f8cb7987c64dcffb72414a40560055cb717dbf74 && cd ..
```

[same-as-file]: <> (utils/build-mlir.cmd)
Expand Down
9 changes: 5 additions & 4 deletions src/Compiler/CompilerUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ int Command::exec(std::string wdir) const {

std::string errMsg;
int rc = llvm::sys::ExecuteAndWait(_path, llvm::ArrayRef(argsRef),
/*Env=*/std::nullopt, /*Redirects=*/std::nullopt,
/*Env=*/{},
/*Redirects=*/{},
/*SecondsToWait=*/0, /*MemoryLimit=*/0, &errMsg);

if (rc != 0) {
Expand Down Expand Up @@ -893,9 +894,9 @@ static std::string getDataLayout(const Location &loc) {
llvm::TargetOptions ops;
std::string mcpuForLLVMToolchain = getTargetCPUOption(
/*forLLVM*/ true, /*cpu only*/ true);
auto targetMachine =
std::unique_ptr<llvm::TargetMachine>{LLVMTarget.createTargetMachine(
mtriple, mcpuForLLVMToolchain, "" /*features*/, ops, std::nullopt)};
auto targetMachine = std::unique_ptr<llvm::TargetMachine>{
LLVMTarget.createTargetMachine(llvm::Triple(mtriple),
mcpuForLLVMToolchain, "" /*features*/, ops, std::nullopt)};
if (!targetMachine) {
emitError(loc, "failed to create target machine");
return nullptr;
Expand Down
6 changes: 2 additions & 4 deletions src/Conversion/ONNXToKrnl/ONNXToKrnlCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ mlir::Value emitScalarOpFor(mlir::ConversionPatternRewriter &rewriter,
llvm::SmallVector<mlir::Value, 4> scalarsSplatted(scalarOperands);
MultiDialectBuilder<MathBuilder> create(rewriter, loc);
create.math.splatToMatch(scalarsSplatted);
return rewriter.create<ScalarIOp<Op>>(
loc, elementType, scalarsSplatted, std::nullopt);
return rewriter.create<ScalarIOp<Op>>(loc, elementType, scalarsSplatted);
}
llvm_unreachable("unsupported integer operation");
} else if (mlir::isa<mlir::FloatType>(actualElementType)) {
Expand All @@ -247,8 +246,7 @@ mlir::Value emitScalarOpFor(mlir::ConversionPatternRewriter &rewriter,
llvm::SmallVector<mlir::Value, 4> scalarsSplatted(scalarOperands);
MultiDialectBuilder<MathBuilder> create(rewriter, loc);
create.math.splatToMatch(scalarsSplatted);
return rewriter.create<ScalarFOp<Op>>(
loc, elementType, scalarsSplatted, std::nullopt);
return rewriter.create<ScalarFOp<Op>>(loc, elementType, scalarsSplatted);
}
llvm_unreachable("unsupported float operation");
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/Conversion/ONNXToKrnl/Tensor/Size.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct ONNXSizeOpLowering : public OpConversionPattern<ONNXSizeOp> {
}
}

create.krnl.store(noElements, alloc, std::nullopt);
create.krnl.store(noElements, alloc, llvm::ArrayRef<mlir::Value>());
rewriter.replaceOp(op, alloc);
onnxToKrnlSimdReport(op);
return success();
Expand Down
4 changes: 2 additions & 2 deletions src/Dialect/Krnl/Krnl.td
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def KrnlYieldOp : Op<Krnl_Dialect, "yield", [Pure, Terminator, ReturnLike,
let arguments = (ins Variadic<AnyType>:$operands);

let builders = [
OpBuilder<(ins), [{ build($_builder, $_state, std::nullopt); }]>
OpBuilder<(ins), [{ build($_builder, $_state, llvm::ArrayRef<mlir::Value>()); }]>
];

let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?";
Expand Down Expand Up @@ -204,7 +204,7 @@ def KrnlIterateOp : Op<Krnl_Dialect, "iterate", [RecursiveMemoryEffects, Implici
let builders = [
// Main builder.
OpBuilder<(ins "onnx_mlir::krnl::KrnlIterateOperandPack":$operandPack,
CArg<"ValueRange", "std::nullopt">:$iterArgs,
CArg<"ValueRange", "llvm::ArrayRef<mlir::Value>()">:$iterArgs,
CArg<"function_ref<void(OpBuilder &, Location, ValueRange, ValueRange, ValueRange)>", "nullptr">:$bodyBuilderFn)>,
// Builder for the optimized iterate op.
OpBuilder<(ins
Expand Down
2 changes: 1 addition & 1 deletion src/Dialect/Mlir/DialectBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1828,7 +1828,7 @@ void SCFBuilder::forLoop(
Value lb, Value ub, int64_t step, SCFLoopBodyFn bodyFn) const {
MathBuilder createMath(*this);
Value stepVal = createMath.constantIndex(step);
b().create<scf::ForOp>(loc(), lb, ub, stepVal, std::nullopt,
b().create<scf::ForOp>(loc(), lb, ub, stepVal, llvm::ArrayRef<mlir::Value>(),
[&](OpBuilder &childBuilder, Location childLoc, Value inductionVar,
ValueRange args) {
SCFBuilder builder(childBuilder, childLoc);
Expand Down
2 changes: 1 addition & 1 deletion src/Dialect/Mlir/IndexExprDetail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ Value IndexExprImpl::getValue() {
// specs involving float and index calculations.
float fval = floatLit;
value = getRewriter().create<arith::ConstantFloatOp>(
getLoc(), llvm::APFloat(fval), getRewriter().getF32Type());
getLoc(), getRewriter().getF32Type(), llvm::APFloat(fval));
} else {
value = getRewriter().create<arith::ConstantIndexOp>(getLoc(), intLit);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Dialect/ONNX/AdditionalONNXOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def ONNXYieldOp : ONNX_Op<"Yield", [Pure, ReturnLike, Terminator]> {

let builders = [
OpBuilder<(ins),
[{ build($_builder, $_state, std::nullopt); }]>];
[{ build($_builder, $_state, llvm::ArrayRef<mlir::Value>()); }]>];

let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?";
}
Expand Down
2 changes: 1 addition & 1 deletion utils/clone-mlir.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
git clone -n https://github.com/llvm/llvm-project.git
# Check out a specific branch that is known to work with ONNX-MLIR.
cd llvm-project && git checkout 7a33569510535f0b917a2e50f644bf57490aee24 && cd ..
cd llvm-project && git checkout f8cb7987c64dcffb72414a40560055cb717dbf74 && cd ..
Loading