diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp --- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp +++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp @@ -706,6 +706,18 @@ } }; +/// Convert `fir.end` +struct FirEndOpConversion : public FIROpConversion { + using FIROpConversion::FIROpConversion; + + mlir::LogicalResult + matchAndRewrite(fir::FirEndOp firEnd, OpAdaptor, + mlir::ConversionPatternRewriter &rewriter) const override { + return rewriter.notifyMatchFailure( + firEnd, "fir.end codegen is not implemented yet"); + } +}; + /// Lower `fir.has_value` operation to `llvm.return` operation. struct HasValueOpConversion : public FIROpConversion { using FIROpConversion::FIROpConversion; @@ -1592,19 +1604,20 @@ mlir::OwningRewritePatternList pattern(context); pattern.insert< AbsentOpConversion, AddcOpConversion, AddrOfOpConversion, - AllocaOpConversion, BoxAddrOpConversion, BoxCharLenOpConversion, BoxDimsOpConversion, - BoxEleSizeOpConversion, BoxIsAllocOpConversion, BoxIsArrayOpConversion, - BoxIsPtrOpConversion, BoxRankOpConversion, CallOpConversion, - CmpcOpConversion, ConvertOpConversion, DispatchOpConversion, - DispatchTableOpConversion, DTEntryOpConversion, DivcOpConversion, - EmboxCharOpConversion, ExtractValueOpConversion, HasValueOpConversion, - GenTypeDescOpConversion, GlobalLenOpConversion, GlobalOpConversion, - InsertOnRangeOpConversion, InsertValueOpConversion, - IsPresentOpConversion, LoadOpConversion, NegcOpConversion, - MulcOpConversion, SelectCaseOpConversion, SelectOpConversion, - SelectRankOpConversion, SelectTypeOpConversion, StoreOpConversion, - SubcOpConversion, UnboxCharOpConversion, UndefOpConversion, - UnreachableOpConversion, ZeroOpConversion>(typeConverter); + AllocaOpConversion, BoxAddrOpConversion, BoxCharLenOpConversion, + BoxDimsOpConversion, BoxEleSizeOpConversion, BoxIsAllocOpConversion, + BoxIsArrayOpConversion, BoxIsPtrOpConversion, BoxRankOpConversion, + CallOpConversion, CmpcOpConversion, ConvertOpConversion, + DispatchOpConversion, DispatchTableOpConversion, DTEntryOpConversion, + DivcOpConversion, EmboxCharOpConversion, ExtractValueOpConversion, + FirEndOpConversion, HasValueOpConversion, GenTypeDescOpConversion, + GlobalLenOpConversion, GlobalOpConversion, InsertOnRangeOpConversion, + InsertValueOpConversion, IsPresentOpConversion, LoadOpConversion, + NegcOpConversion, MulcOpConversion, SelectCaseOpConversion, + SelectOpConversion, SelectRankOpConversion, SelectTypeOpConversion, + StoreOpConversion, SubcOpConversion, UnboxCharOpConversion, + UndefOpConversion, UnreachableOpConversion, ZeroOpConversion>( + typeConverter); mlir::populateStdToLLVMConversionPatterns(typeConverter, pattern); mlir::arith::populateArithmeticToLLVMConversionPatterns(typeConverter, pattern); diff --git a/flang/test/Fir/convert-to-llvm-invalid.fir b/flang/test/Fir/convert-to-llvm-invalid.fir --- a/flang/test/Fir/convert-to-llvm-invalid.fir +++ b/flang/test/Fir/convert-to-llvm-invalid.fir @@ -93,3 +93,10 @@ %0 = fir.gentypedesc !fir.type return } + +// ----- + +// Test `fir.end` conversion failure. Not implemented yet. + +// expected-error@+1{{failed to legalize operation 'fir.end'}} +"fir.end"() : () -> ()