Skip to content

Commit f6559a2

Browse files
committed
Bump LLVM to 289b17635958d986b74683c932df6b1d12f37b70.
This picked up a few breaking changes. llvm/llvm-project@327d6270 This added new required methods to CallOpInterface and CallableOpInterface. These methods are related to arrays of dictionary attributes for each argument and result, and are normally implemented upstream by simply defining the right arg_attrs and res_attrs arguments on the operations. This allows some of the common utilities upstream to work with the attributes. However, we seem to have actually moved away from arrays of per-argument or per-result attributes in most cases, and handle this ourselves when we want to. I opted to stub out the methods in the tablegen definitions of our operations, rather than adding optional attributes and setting them to null in builders and builder callsites like was done upstream. There were also some accompanying name changes to a couple helper functions, which we were able to simply apply without needing to add new optional attributes everywhere. llvm/llvm-project@e84f6b6a This updated several LLVM dialect helper functions related to lookupOrCreateFn to return FailureOr<LLVM::LLVMFuncOp>. In most cases, we simply check for the error case and return it or signal pass failure. There was one function in the SMT to Z3 conversion that assumes this always succeeds and in this function I made an assertion rather than changing the function to also potentially return failure. llvm/llvm-project@f4e3b878 Looks like upstream is simply moving from undef to poison in many cases, so this required us to update one test case.
1 parent 2b25325 commit f6559a2

File tree

16 files changed

+159
-23
lines changed

16 files changed

+159
-23
lines changed

include/circt/Dialect/Arc/ArcOps.td

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,16 @@ def StateOp : ArcOp<"state", [
237237
void setCalleeFromCallable(mlir::CallInterfaceCallable callee) {
238238
(*this)->setAttr(getArcAttrName(), llvm::cast<mlir::SymbolRefAttr>(callee));
239239
}
240+
241+
/// Stub implementations for ArgumentAttributesMethods. If desired,
242+
/// implement these by defining arg_attrs and res_attrs as arguments to the
243+
/// operation as OptionalAttr<DictArrayAttr>.
244+
mlir::ArrayAttr getArgAttrsAttr() { return nullptr; }
245+
mlir::ArrayAttr getResAttrsAttr() { return nullptr; }
246+
void setArgAttrsAttr(mlir::ArrayAttr args) {}
247+
void setResAttrsAttr(mlir::ArrayAttr args) {}
248+
mlir::Attribute removeArgAttrsAttr() { return nullptr; }
249+
mlir::Attribute removeResAttrsAttr() { return nullptr; }
240250
}];
241251
}
242252

@@ -278,6 +288,16 @@ def CallOp : ArcOp<"call", [
278288
void setCalleeFromCallable(mlir::CallInterfaceCallable callee) {
279289
(*this)->setAttr(getArcAttrName(), llvm::cast<mlir::SymbolRefAttr>(callee));
280290
}
291+
292+
/// Stub implementations for ArgumentAttributesMethods. If desired,
293+
/// implement these by defining arg_attrs and res_attrs as arguments to the
294+
/// operation as OptionalAttr<DictArrayAttr>.
295+
mlir::ArrayAttr getArgAttrsAttr() { return nullptr; }
296+
mlir::ArrayAttr getResAttrsAttr() { return nullptr; }
297+
void setArgAttrsAttr(mlir::ArrayAttr args) {}
298+
void setResAttrsAttr(mlir::ArrayAttr args) {}
299+
mlir::Attribute removeArgAttrsAttr() { return nullptr; }
300+
mlir::Attribute removeResAttrsAttr() { return nullptr; }
281301
}];
282302
}
283303

@@ -367,6 +387,16 @@ def MemoryWritePortOp : ArcOp<"memory_write_port", [
367387
void setCalleeFromCallable(mlir::CallInterfaceCallable callee) {
368388
(*this)->setAttr(getArcAttrName(), llvm::cast<mlir::SymbolRefAttr>(callee));
369389
}
390+
391+
/// Stub implementations for ArgumentAttributesMethods. If desired,
392+
/// implement these by defining arg_attrs and res_attrs as arguments to the
393+
/// operation as OptionalAttr<DictArrayAttr>.
394+
mlir::ArrayAttr getArgAttrsAttr() { return nullptr; }
395+
mlir::ArrayAttr getResAttrsAttr() { return nullptr; }
396+
void setArgAttrsAttr(mlir::ArrayAttr args) {}
397+
void setResAttrsAttr(mlir::ArrayAttr args) {}
398+
mlir::Attribute removeArgAttrsAttr() { return nullptr; }
399+
mlir::Attribute removeResAttrsAttr() { return nullptr; }
370400
}];
371401
}
372402

include/circt/Dialect/Handshake/HandshakeOps.td

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,16 @@ def ESIInstanceOp : Op<Handshake_Dialect, "esi_instance", [
186186
MutableOperandRange getArgOperandsMutable() {
187187
return getOpOperandsMutable();
188188
}
189+
190+
/// Stub implementations for ArgumentAttributesMethods. If desired,
191+
/// implement these by defining arg_attrs and res_attrs as arguments to the
192+
/// operation as OptionalAttr<DictArrayAttr>.
193+
mlir::ArrayAttr getArgAttrsAttr() { return nullptr; }
194+
mlir::ArrayAttr getResAttrsAttr() { return nullptr; }
195+
void setArgAttrsAttr(mlir::ArrayAttr args) {}
196+
void setResAttrsAttr(mlir::ArrayAttr args) {}
197+
mlir::Attribute removeArgAttrsAttr() { return nullptr; }
198+
mlir::Attribute removeResAttrsAttr() { return nullptr; }
189199
}];
190200
}
191201

@@ -263,6 +273,15 @@ def InstanceOp : Handshake_Op<"instance", [
263273
return getOpOperandsMutable();
264274
}
265275

276+
/// Stub implementations for ArgumentAttributesMethods. If desired,
277+
/// implement these by defining arg_attrs and res_attrs as arguments to the
278+
/// operation as OptionalAttr<DictArrayAttr>.
279+
mlir::ArrayAttr getArgAttrsAttr() { return nullptr; }
280+
mlir::ArrayAttr getResAttrsAttr() { return nullptr; }
281+
void setArgAttrsAttr(mlir::ArrayAttr args) {}
282+
void setResAttrsAttr(mlir::ArrayAttr args) {}
283+
mlir::Attribute removeArgAttrsAttr() { return nullptr; }
284+
mlir::Attribute removeResAttrsAttr() { return nullptr; }
266285
}];
267286

268287
let assemblyFormat = [{

include/circt/Dialect/Kanagawa/KanagawaOps.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,16 @@ def CallOp : KanagawaOp<"call", [
464464

465465
/// Return the callee of this operation.
466466
MethodOp getTarget(const hw::InnerRefNamespace &symbolTable);
467+
468+
/// Stub implementations for ArgumentAttributesMethods. If desired,
469+
/// implement these by defining arg_attrs and res_attrs as arguments to the
470+
/// operation as OptionalAttr<DictArrayAttr>.
471+
mlir::ArrayAttr getArgAttrsAttr() { return nullptr; }
472+
mlir::ArrayAttr getResAttrsAttr() { return nullptr; }
473+
void setArgAttrsAttr(mlir::ArrayAttr args) {}
474+
void setResAttrsAttr(mlir::ArrayAttr args) {}
475+
mlir::Attribute removeArgAttrsAttr() { return nullptr; }
476+
mlir::Attribute removeResAttrsAttr() { return nullptr; }
467477
}];
468478

469479
let assemblyFormat = [{

include/circt/Dialect/SV/SVStatements.td

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,16 @@ def FuncOp : SVOp<"func",
10021002
void getAsmBlockArgumentNames(mlir::Region &region,
10031003
mlir::OpAsmSetValueNameFn setNameFn);
10041004
SmallVector<hw::PortInfo> getPortList(bool excludeExplicitReturn);
1005+
1006+
/// Stub implementations for ArgumentAttributesMethods. If desired,
1007+
/// implement these by defining arg_attrs and res_attrs as arguments to the
1008+
/// operation as OptionalAttr<DictArrayAttr>.
1009+
mlir::ArrayAttr getArgAttrsAttr() { return nullptr; }
1010+
mlir::ArrayAttr getResAttrsAttr() { return nullptr; }
1011+
void setArgAttrsAttr(mlir::ArrayAttr args) {}
1012+
void setResAttrsAttr(mlir::ArrayAttr args) {}
1013+
mlir::Attribute removeArgAttrsAttr() { return nullptr; }
1014+
mlir::Attribute removeResAttrsAttr() { return nullptr; }
10051015
}];
10061016
let extraClassDefinition = [{
10071017
hw::ModuleType $cppClass::getHWModuleType() {
@@ -1066,6 +1076,16 @@ class SVFuncCallBase<string mnemonic, list<Trait> traits = []>: SVOp<mnemonic,
10661076
void setCalleeFromCallable(mlir::CallInterfaceCallable callee) {
10671077
(*this)->setAttr(getCalleeAttrName(), llvm::cast<mlir::SymbolRefAttr>(callee));
10681078
}
1079+
1080+
/// Stub implementations for ArgumentAttributesMethods. If desired,
1081+
/// implement these by defining arg_attrs and res_attrs as arguments to the
1082+
/// operation as OptionalAttr<DictArrayAttr>.
1083+
mlir::ArrayAttr getArgAttrsAttr() { return nullptr; }
1084+
mlir::ArrayAttr getResAttrsAttr() { return nullptr; }
1085+
void setArgAttrsAttr(mlir::ArrayAttr args) {}
1086+
void setResAttrsAttr(mlir::ArrayAttr args) {}
1087+
mlir::Attribute removeArgAttrsAttr() { return nullptr; }
1088+
mlir::Attribute removeResAttrsAttr() { return nullptr; }
10691089
}];
10701090
}
10711091

include/circt/Dialect/Sim/SimOps.td

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,16 @@ def DPIFuncOp : SimOp<"func.dpi",
9595
ArrayRef<Type> getResultTypes() { return getFunctionType().getResults(); }
9696

9797
::mlir::Region *getCallableRegion() { return nullptr; }
98+
99+
/// Stub implementations for ArgumentAttributesMethods. If desired,
100+
/// implement these by defining arg_attrs and res_attrs as arguments to the
101+
/// operation as OptionalAttr<DictArrayAttr>.
102+
mlir::ArrayAttr getArgAttrsAttr() { return nullptr; }
103+
mlir::ArrayAttr getResAttrsAttr() { return nullptr; }
104+
void setArgAttrsAttr(mlir::ArrayAttr args) {}
105+
void setResAttrsAttr(mlir::ArrayAttr args) {}
106+
mlir::Attribute removeArgAttrsAttr() { return nullptr; }
107+
mlir::Attribute removeResAttrsAttr() { return nullptr; }
98108
}];
99109
}
100110

@@ -145,6 +155,16 @@ def DPICallOp : SimOp<"func.dpi.call",
145155
void setCalleeFromCallable(mlir::CallInterfaceCallable callee) {
146156
(*this)->setAttr(getCalleeAttrName(), llvm::cast<mlir::SymbolRefAttr>(callee));
147157
}
158+
159+
/// Stub implementations for ArgumentAttributesMethods. If desired,
160+
/// implement these by defining arg_attrs and res_attrs as arguments to the
161+
/// operation as OptionalAttr<DictArrayAttr>.
162+
mlir::ArrayAttr getArgAttrsAttr() { return nullptr; }
163+
mlir::ArrayAttr getResAttrsAttr() { return nullptr; }
164+
void setArgAttrsAttr(mlir::ArrayAttr args) {}
165+
void setResAttrsAttr(mlir::ArrayAttr args) {}
166+
mlir::Attribute removeArgAttrsAttr() { return nullptr; }
167+
mlir::Attribute removeResAttrsAttr() { return nullptr; }
148168
}];
149169

150170
}

include/circt/Dialect/SystemC/SystemCStatements.td

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,15 @@ def CallIndirectOp : SystemCOp<"cpp.call_indirect", [
286286
abort();
287287
}
288288

289+
/// Stub implementations for ArgumentAttributesMethods. If desired,
290+
/// implement these by defining arg_attrs and res_attrs as arguments to the
291+
/// operation as OptionalAttr<DictArrayAttr>.
292+
mlir::ArrayAttr getArgAttrsAttr() { return nullptr; }
293+
mlir::ArrayAttr getResAttrsAttr() { return nullptr; }
294+
void setArgAttrsAttr(mlir::ArrayAttr args) {}
295+
void setResAttrsAttr(mlir::ArrayAttr args) {}
296+
mlir::Attribute removeArgAttrsAttr() { return nullptr; }
297+
mlir::Attribute removeResAttrsAttr() { return nullptr; }
289298
}];
290299

291300
let assemblyFormat = [{
@@ -364,6 +373,15 @@ def CallOp : SystemCOp<"cpp.call", [
364373
(*this)->setAttr(getCalleeAttrName(), llvm::cast<mlir::SymbolRefAttr>(callee));
365374
}
366375

376+
/// Stub implementations for ArgumentAttributesMethods. If desired,
377+
/// implement these by defining arg_attrs and res_attrs as arguments to the
378+
/// operation as OptionalAttr<DictArrayAttr>.
379+
mlir::ArrayAttr getArgAttrsAttr() { return nullptr; }
380+
mlir::ArrayAttr getResAttrsAttr() { return nullptr; }
381+
void setArgAttrsAttr(mlir::ArrayAttr args) {}
382+
void setResAttrsAttr(mlir::ArrayAttr args) {}
383+
mlir::Attribute removeArgAttrsAttr() { return nullptr; }
384+
mlir::Attribute removeResAttrsAttr() { return nullptr; }
367385
}];
368386

369387
let assemblyFormat = [{

integration_test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ set(CIRCT_INTEGRATION_TEST_DEPENDS
1919
)
2020

2121
if (MLIR_ENABLE_EXECUTION_ENGINE)
22-
list(APPEND CIRCT_INTEGRATION_TEST_DEPENDS mlir-cpu-runner)
22+
list(APPEND CIRCT_INTEGRATION_TEST_DEPENDS mlir-runner)
2323
endif()
2424

2525
# If Python bindings are available to build then enable the tests.

lib/Conversion/ArcToLLVM/LowerArcToLLVM.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -381,17 +381,22 @@ struct SimInstantiateOpLowering
381381
// sizeof(size_t) on the target architecture.
382382
Type convertedIndex = typeConverter->convertType(rewriter.getIndexType());
383383

384-
LLVM::LLVMFuncOp mallocFunc =
384+
FailureOr<LLVM::LLVMFuncOp> mallocFunc =
385385
LLVM::lookupOrCreateMallocFn(moduleOp, convertedIndex);
386-
LLVM::LLVMFuncOp freeFunc = LLVM::lookupOrCreateFreeFn(moduleOp);
386+
if (failed(mallocFunc))
387+
return mallocFunc;
388+
389+
FailureOr<LLVM::LLVMFuncOp> freeFunc = LLVM::lookupOrCreateFreeFn(moduleOp);
390+
if (failed(freeFunc))
391+
return freeFunc;
387392

388393
Location loc = op.getLoc();
389394
Value numStateBytes = rewriter.create<LLVM::ConstantOp>(
390395
loc, convertedIndex, model.numStateBytes);
391-
Value allocated =
392-
rewriter
393-
.create<LLVM::CallOp>(loc, mallocFunc, ValueRange{numStateBytes})
394-
.getResult();
396+
Value allocated = rewriter
397+
.create<LLVM::CallOp>(loc, mallocFunc.value(),
398+
ValueRange{numStateBytes})
399+
.getResult();
395400
Value zero =
396401
rewriter.create<LLVM::ConstantOp>(loc, rewriter.getI8Type(), 0);
397402
rewriter.create<LLVM::MemsetOp>(loc, allocated, zero, numStateBytes, false);
@@ -418,7 +423,7 @@ struct SimInstantiateOpLowering
418423
ValueRange{allocated});
419424
}
420425

421-
rewriter.create<LLVM::CallOp>(loc, freeFunc, ValueRange{allocated});
426+
rewriter.create<LLVM::CallOp>(loc, freeFunc.value(), ValueRange{allocated});
422427
rewriter.eraseOp(op);
423428

424429
return success();
@@ -550,6 +555,8 @@ struct SimEmitValueOpLowering
550555
auto printfFunc = LLVM::lookupOrCreateFn(
551556
moduleOp, "printf", LLVM::LLVMPointerType::get(getContext()),
552557
LLVM::LLVMVoidType::get(getContext()), true);
558+
if (failed(printfFunc))
559+
return printfFunc;
553560

554561
// Insert the format string if not already available.
555562
SmallString<16> formatStrName{"_arc_sim_emit_"};
@@ -580,7 +587,7 @@ struct SimEmitValueOpLowering
580587
Value formatStrGlobalPtr =
581588
rewriter.create<LLVM::AddressOfOp>(loc, formatStrGlobal);
582589
rewriter.replaceOpWithNewOp<LLVM::CallOp>(
583-
op, printfFunc, ValueRange{formatStrGlobalPtr, toPrint});
590+
op, printfFunc.value(), ValueRange{formatStrGlobalPtr, toPrint});
584591

585592
return success();
586593
}

lib/Conversion/SMTToZ3LLVM/LowerSMTToZ3LLVM.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,11 @@ class SMTLoweringPattern : public OpConversionPattern<OpTy> {
149149
auto module =
150150
builder.getBlock()->getParent()->getParentOfType<ModuleOp>();
151151
builder.setInsertionPointToEnd(module.getBody());
152-
funcOp = LLVM::lookupOrCreateFn(module, name, funcType.getParams(),
153-
funcType.getReturnType(),
154-
funcType.getVarArg());
152+
auto funcOpResult = LLVM::lookupOrCreateFn(
153+
module, name, funcType.getParams(), funcType.getReturnType(),
154+
funcType.getVarArg());
155+
assert(succeeded(funcOpResult) && "expected to lookup or create printf");
156+
funcOp = funcOpResult.value();
155157
}
156158
return builder.create<LLVM::CallOp>(loc, funcOp, args);
157159
}

lib/Dialect/FSM/FSMOps.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void MachineOp::build(OpBuilder &builder, OperationState &state, StringRef name,
4444
if (argAttrs.empty())
4545
return;
4646
assert(type.getNumInputs() == argAttrs.size());
47-
function_interface_impl::addArgAndResultAttrs(
47+
call_interface_impl::addArgAndResultAttrs(
4848
builder, state, argAttrs,
4949
/*resultAttrs=*/std::nullopt, MachineOp::getArgAttrsAttrName(state.name),
5050
MachineOp::getResAttrsAttrName(state.name));

lib/Dialect/Handshake/HandshakeOps.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ parseFuncOpArgs(OpAsmParser &parser,
550550
SmallVectorImpl<Type> &resTypes,
551551
SmallVectorImpl<DictionaryAttr> &resAttrs) {
552552
bool isVariadic;
553-
if (mlir::function_interface_impl::parseFunctionSignature(
553+
if (mlir::function_interface_impl::parseFunctionSignatureWithArguments(
554554
parser, /*allowVariadic=*/true, entryArgs, isVariadic, resTypes,
555555
resAttrs)
556556
.failed())
@@ -641,7 +641,7 @@ ParseResult FuncOp::parse(OpAsmParser &parser, OperationState &result) {
641641
result.attributes) ||
642642
parseFuncOpArgs(parser, args, resTypes, resAttributes))
643643
return failure();
644-
mlir::function_interface_impl::addArgAndResultAttrs(
644+
mlir::call_interface_impl::addArgAndResultAttrs(
645645
builder, result, args, resAttributes,
646646
handshake::FuncOp::getArgAttrsAttrName(result.name),
647647
handshake::FuncOp::getResAttrsAttrName(result.name));

lib/Dialect/SystemC/SystemCOps.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ ParseResult SCModuleOp::parse(OpAsmParser &parser, OperationState &result) {
171171
result.addAttribute(SCModuleOp::getFunctionTypeAttrName(result.name),
172172
functionType);
173173

174-
mlir::function_interface_impl::addArgAndResultAttrs(
174+
mlir::call_interface_impl::addArgAndResultAttrs(
175175
parser.getBuilder(), result, entryArgs, resultAttrs,
176176
SCModuleOp::getArgAttrsAttrName(result.name),
177177
SCModuleOp::getResAttrsAttrName(result.name));
@@ -855,7 +855,7 @@ void FuncOp::build(OpBuilder &odsBuilder, OperationState &odsState,
855855
if (argAttrs.empty())
856856
return;
857857
assert(type.getNumInputs() == argAttrs.size());
858-
mlir::function_interface_impl::addArgAndResultAttrs(
858+
mlir::call_interface_impl::addArgAndResultAttrs(
859859
odsBuilder, odsState, argAttrs,
860860
/*resultAttrs=*/std::nullopt, FuncOp::getArgAttrsAttrName(odsState.name),
861861
FuncOp::getResAttrsAttrName(odsState.name));
@@ -893,7 +893,7 @@ ParseResult FuncOp::parse(OpAsmParser &parser, OperationState &result) {
893893
// Parse the function signature.
894894
mlir::SMLoc signatureLocation = parser.getCurrentLocation();
895895
bool isVariadic = false;
896-
if (mlir::function_interface_impl::parseFunctionSignature(
896+
if (mlir::function_interface_impl::parseFunctionSignatureWithArguments(
897897
parser, false, entryArgs, isVariadic, resultTypes, resultAttrs))
898898
return failure();
899899

@@ -935,7 +935,7 @@ ParseResult FuncOp::parse(OpAsmParser &parser, OperationState &result) {
935935

936936
// Add the attributes to the function arguments.
937937
assert(resultAttrs.size() == resultTypes.size());
938-
mlir::function_interface_impl::addArgAndResultAttrs(
938+
mlir::call_interface_impl::addArgAndResultAttrs(
939939
builder, result, entryArgs, resultAttrs,
940940
FuncOp::getArgAttrsAttrName(result.name),
941941
FuncOp::getResAttrsAttrName(result.name));

lib/Tools/circt-bmc/LowerToBMC.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ void LowerToBMCPass::runOnOperation() {
7777
// Lookup or declare printf function.
7878
auto printfFunc =
7979
LLVM::lookupOrCreateFn(moduleOp, "printf", ptrTy, voidTy, true);
80+
if (failed(printfFunc)) {
81+
moduleOp->emitError("failed to lookup or create printf");
82+
return signalPassFailure();
83+
}
8084

8185
// Replace the top-module with a function performing the BMC
8286
auto entryFunc = builder.create<func::FuncOp>(
@@ -203,7 +207,8 @@ void LowerToBMCPass::runOnOperation() {
203207

204208
auto formatString = builder.create<LLVM::SelectOp>(
205209
loc, bmcOp.getResult(), successStrAddr.value(), failureStrAddr.value());
206-
builder.create<LLVM::CallOp>(loc, printfFunc, ValueRange{formatString});
210+
builder.create<LLVM::CallOp>(loc, printfFunc.value(),
211+
ValueRange{formatString});
207212
builder.create<func::ReturnOp>(loc);
208213

209214
if (insertMainFunc) {

lib/Tools/circt-lec/ConstructLEC.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ void ConstructLECPass::runOnOperation() {
7575
// Lookup or declare printf function.
7676
auto printfFunc =
7777
LLVM::lookupOrCreateFn(getOperation(), "printf", ptrTy, voidTy, true);
78+
if (failed(printfFunc)) {
79+
getOperation()->emitError("failed to lookup or create printf");
80+
return signalPassFailure();
81+
}
7882

7983
// Lookup the modules.
8084
auto moduleA = lookupModule(firstModule);
@@ -144,7 +148,8 @@ void ConstructLECPass::runOnOperation() {
144148
lookupOrCreateStringGlobal(builder, getOperation(), "c1 != c2\n");
145149
Value formatString = builder.create<LLVM::SelectOp>(
146150
loc, areEquivalent, eqFormatString, neqFormatString);
147-
builder.create<LLVM::CallOp>(loc, printfFunc, ValueRange{formatString});
151+
builder.create<LLVM::CallOp>(loc, printfFunc.value(),
152+
ValueRange{formatString});
148153

149154
builder.create<func::ReturnOp>(loc, ValueRange{});
150155
}

llvm

Submodule llvm updated 6943 files

test/Conversion/ArcToLLVM/lower-arc-to-llvm.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func.func @funcCallOp(%arg0: i32) -> (i32, i32) {
164164
// CHECK-NEXT: [[V1:%.+]] = llvm.extractvalue [[V0]][0] : !llvm.struct<(i32, i32)>
165165
// CHECK-NEXT: [[V2:%.+]] = llvm.extractvalue [[V0]][1] : !llvm.struct<(i32, i32)>
166166
%0:2 = func.call @dummyFuncCallee(%arg0) : (i32) -> (i32, i32)
167-
// CHECK-NEXT: [[V3:%.+]] = llvm.mlir.undef : !llvm.struct<(i32, i32)>
167+
// CHECK-NEXT: [[V3:%.+]] = llvm.mlir.poison : !llvm.struct<(i32, i32)>
168168
// CHECK-NEXT: [[V4:%.+]] = llvm.insertvalue [[V1]], [[V3]][0] : !llvm.struct<(i32, i32)>
169169
// CHECK-NEXT: [[V5:%.+]] = llvm.insertvalue [[V2]], [[V4]][1] : !llvm.struct<(i32, i32)>
170170
// CHECK-NEXT: llvm.return [[V5]] :

0 commit comments

Comments
 (0)