LLVM Discussion Forums

Error When using mlir-cpu-runner

I have reduced an onnx model to LLVM IR, then when using mlpir-cpu-runner to execute, it generates the following error.

llvm-project-master/build/bin/mlir-cpu-runner llvm.mlir
loc(“llvm.mlir”:273:45): error: custom op ‘llvm.insertvalue’ expected wrapped LLVM IR structure/array type
could not parse the input IR

1 Like

I suppose you mean “LLVM dialect”, not “LLVM IR”. mlir-cpu-runner won’t run LLVM IR (lli will) We need to see the IR that caused the problem. The error clearly says some insertvalue instruction is called on a value of a wrong type.

Alex thank you for the quick response.This is the IR that caused the problem.

> 265   llvm.func @_dyn_entry_point_main_graph(%arg0: !llvm<"i8*">) -> !llvm<"i8*"> {
> 266    %0 = llvm.mlir.constant(0 : i32) : !llvm.i32
> 267    %1 = llvm.call @getDynMemRef(%arg0, %0) : (!llvm<"i8*">, !llvm.i32) -> 
                       !llvm<"i8*">
> 268    %2 = llvm.mlir.constant(1 : i32) : !llvm.i32
> 269   %3 = llvm.alloca %2 x !llvm<"{ float*, float*, i64, [2 x i64], [2 x i64] }"> : (!llvm.i32) ->                    !llvm<"{ float*, float*, i64, [2 x i64], [2 x i64] }*">
> 270    %4 = llvm.load %3 : !llvm<"{ float*, float*, i64, [2 x i64], [2 x i64] }*">
> 271   %5 = llvm.call @getData(%1) : (!llvm<"i8*">) -> !llvm<"i8*">
> 272    %6 = llvm.bitcast %5 : !llvm<"i8*"> to !llvm<"float*">
> 273    %7 = llvm.insertvalue %6, %4[0 : i32] : !llvm<"{ float*, float*, i64, [2 x i64], [2 x i64] 
                       }*">
> 274    %8 = llvm.insertvalue %6, %7[1 : i32] : !llvm<"{ float*, float*, i64, [2 x i64], [2 x i64] 
                       }">
> 275    %9 = llvm.mlir.constant(0 : i64) : !llvm.i64

Something happened with the formatting (specifically, some * got interpreted by markdown), so I can’t see the proper types. Maybe paste it on github gist?

Yeah sure this is the gist link to the code : https://gist.github.com/AkhilJ99/c1bd64e4262a488cd5296694161606a1

Yeah, it’s exactly what the error message says:

%7 = llvm.insertvalue %6, %4[0 : i32] : !llvm<"{ float*, float*, i64, [2 x i64], [2 x i64] }*">

tries to call insertvalue on a pointer, rather than a structure. %4 comes from an llvm.load, so it shouldn’t be a pointer. Look into the code that constructs insertvalue that may be passing the wrong type into the constructor.

FYI: use triple quotes in Discourse for code-block