Index: flang/include/flang/Tools/CLOptions.inc =================================================================== --- flang/include/flang/Tools/CLOptions.inc +++ flang/include/flang/Tools/CLOptions.inc @@ -66,6 +66,8 @@ "rewrite boxed procedures"); #endif +DisableOption(ExternalNameConversion, "external-name-interop", "convert names with external convention"); + /// Generic for adding a pass to the pass manager if it is not disabled. template void addPassConditionally( @@ -139,6 +141,11 @@ } #endif +inline void addExternalNameConversionPass(mlir::PassManager &pm) { + addPassConditionally(pm, disableExternalNameConversion, + [&]() { return fir::createExternalNameConversionPass(); }); +} + /// Create a pass pipeline for running default optimization passes for /// incremental conversion of FIR. /// @@ -174,6 +181,7 @@ pm.addNestedPass(fir::createAbstractResultOptPass()); fir::addCodeGenRewritePass(pm); fir::addTargetRewritePass(pm); + fir::addExternalNameConversionPass(pm); fir::addFIRToLLVMPass(pm); } Index: flang/test/Driver/pass-pipeline.f90 =================================================================== --- /dev/null +++ flang/test/Driver/pass-pipeline.f90 @@ -0,0 +1,33 @@ +! Test the pass pipeline + +! FIXME: Also check LLVM passes +! RUN: %flang_fc1 -S -mmlir --pass-statistics -mmlir --pass-statistics-display=pipeline %s -o - 2>&1 | FileCheck %s +end program + +! CHECK: Pass statistics report + +! CHECK-LABEL: 'func.func' Pipeline +! CHECK: ArrayValueCopy +! CHECK: CharacterConversion +! CHECK: Canonicalizer +! CHECK: SimplifyRegionLite + +! CHECK-LABEL: 'func.func' Pipeline +! CHECK: MemoryAllocationOpt +! CHECK: Inliner +! CHECK: CSE + +! CHECK-LABEL: 'func.func' Pipeline +! CHECK: CFGConversion +! CHECK: SCFToControlFlow +! CHECK: Canonicalizer +! CHECK: SimplifyRegionLite +! CHECK: BoxedProcedurePass + +! CHECK-LABEL: 'func.func' Pipeline +! CHECK: AbstractResultOpt +! CHECK: CodeGenRewrite +! CHECK: TargetRewrite +! CHECK: ExternalNameConversion +! CHECK: FIRToLLVMLowering +! CHECK-NOT: LLVMIRLoweringPass Index: flang/test/Fir/basic-program.fir =================================================================== --- flang/test/Fir/basic-program.fir +++ flang/test/Fir/basic-program.fir @@ -1,6 +1,8 @@ // RUN: tco %s | FileCheck %s +// RUN: tco %s --pass-statistics --pass-statistics-display=pipeline 2>&1 | FileCheck %s --check-prefix=PASSES // Check that tco is working with a basic test. +// Also check the passes in the default pipeline. func @_QQmain() { return @@ -9,3 +11,31 @@ // CHECK: ; ModuleID = 'FIRModule' // CHECK-LABEL: define void @_QQmain() // CHECK: ret void + +// PASSES: Pass statistics report + +// PASSES-LABEL: 'func.func' Pipeline +// PASSES: ArrayValueCopy +// PASSES: CharacterConversion +// PASSES: Canonicalizer +// PASSES: SimplifyRegionLite + +// PASSES-LABEL: 'func.func' Pipeline +// PASSES: MemoryAllocationOpt +// PASSES: Inliner +// PASSES: CSE + +// PASSES-LABEL: 'func.func' Pipeline +// PASSES: CFGConversion +// PASSES: SCFToControlFlow +// PASSES: Canonicalizer +// PASSES: SimplifyRegionLite +// PASSES: BoxedProcedurePass + +// PASSES-LABEL: 'func.func' Pipeline +// PASSES: AbstractResultOpt +// PASSES: CodeGenRewrite +// PASSES: TargetRewrite +// PASSES: ExternalNameConversion +// PASSES: FIRToLLVMLowering +// PASSES: LLVMIRLoweringPass Index: flang/test/Fir/embox.fir =================================================================== --- flang/test/Fir/embox.fir +++ flang/test/Fir/embox.fir @@ -1,4 +1,4 @@ -// RUN: fir-opt %s | tco | FileCheck %s +// RUN: fir-opt %s | tco -disable-external-name-interop | FileCheck %s // CHECK-LABEL: define void @_QPtest_callee({ i32*, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }* %0) Index: flang/test/Lower/common-block.f90 =================================================================== --- flang/test/Lower/common-block.f90 +++ flang/test/Lower/common-block.f90 @@ -1,4 +1,4 @@ -! RUN: bbc %s -o - | tco | FileCheck %s +! RUN: bbc %s -o - | tco -disable-external-name-interop | FileCheck %s ! CHECK: @_QB = common global [8 x i8] zeroinitializer ! CHECK: @_QBx = global { float, float } { float 1.0{{.*}}, float 2.0{{.*}} }