mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-19 13:16:46 +00:00
[Flang][bbc] Prevent bbc -emit-fir command invoking OpenMP passes twice (#80927)
Currently when the bbc tool is invoked with the emit-fir command the pass pipeline will be invoked twice for verification causing the previously added OpenMP pass pipeline to be invoked multiple times. This change seeks to prevent that from occurring by using a seperate pass manager and run command immediately when it is necessary for the OpenMP passes to be executed.
This commit is contained in:
parent
6ea76c1328
commit
ec1fcb381d
@ -256,6 +256,22 @@ createTargetMachine(llvm::StringRef targetTriple, std::string &error) {
|
||||
/*Reloc::Model=*/std::nullopt)};
|
||||
}
|
||||
|
||||
/// Build and execute the OpenMPFIRPassPipeline with its own instance
|
||||
/// of the pass manager, allowing it to be invoked as soon as it's
|
||||
/// required without impacting the main pass pipeline that may be invoked
|
||||
/// more than once for verification.
|
||||
static mlir::LogicalResult runOpenMPPasses(mlir::ModuleOp mlirModule) {
|
||||
mlir::PassManager pm(mlirModule->getName(),
|
||||
mlir::OpPassManager::Nesting::Implicit);
|
||||
fir::createOpenMPFIRPassPipeline(pm, enableOpenMPDevice);
|
||||
(void)mlir::applyPassManagerCLOptions(pm);
|
||||
if (mlir::failed(pm.run(mlirModule))) {
|
||||
llvm::errs() << "FATAL: failed to correctly apply OpenMP pass pipeline";
|
||||
return mlir::failure();
|
||||
}
|
||||
return mlir::success();
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Translate Fortran input to FIR, a dialect of MLIR.
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -369,14 +385,16 @@ static mlir::LogicalResult convertFortranSourceToMLIR(
|
||||
"could not open output file ")
|
||||
<< outputName;
|
||||
|
||||
// WARNING: This pipeline must be run immediately after the lowering to
|
||||
// ensure that the FIR is correct with respect to OpenMP operations/
|
||||
// attributes.
|
||||
if (enableOpenMP)
|
||||
if (mlir::failed(runOpenMPPasses(mlirModule)))
|
||||
return mlir::failure();
|
||||
|
||||
// Otherwise run the default passes.
|
||||
mlir::PassManager pm(mlirModule->getName(),
|
||||
mlir::OpPassManager::Nesting::Implicit);
|
||||
if (enableOpenMP)
|
||||
// WARNING: This pipeline must be run immediately after the lowering to
|
||||
// ensure that the FIR is correct with respect to OpenMP operations/
|
||||
// attributes.
|
||||
fir::createOpenMPFIRPassPipeline(pm, enableOpenMPDevice);
|
||||
pm.enableVerifier(/*verifyPasses=*/true);
|
||||
(void)mlir::applyPassManagerCLOptions(pm);
|
||||
if (passPipeline.hasAnyOccurrences()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user