From 2e634367be6a2ed6b8a4ee5c29b720dd90c0d70a Mon Sep 17 00:00:00 2001 From: Andrew Gozillon Date: Mon, 24 Apr 2023 09:46:03 -0500 Subject: [Flang][OpenMP][Driver][MLIR] Port fopenmp-host-ir-file-path flag and add MLIR module attribute to proliferate to OpenMP IR lowering This patch ports the fopenmp-host-ir-file-path flag from Clang to Flang-new, this flag is added by the driver to the device pass when doing two phase compilation (device + host). This flag is then applied to the module when compiling during the OpenMP device phase. This file can then be utilised during lowering of the OpenMP dialect to LLVM-IR, which allows the device and host to maintain 1:1 mapping of OpenMP metadata for variables during lowering via the OpenMPIRBuilders loadOffloadInfoMetadata facilities (which is used for declare target and I believe target regions as well). Reviewer: awarzynski Differential Revision: https://reviews.llvm.org/D148038 --- flang/lib/Frontend/CompilerInvocation.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'flang/lib/Frontend/CompilerInvocation.cpp') diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index c6d5152..6672777 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -726,6 +726,16 @@ static bool parseDialectArgs(CompilerInvocation &res, llvm::opt::ArgList &args, if (args.hasArg(clang::driver::options::OPT_fopenmp_is_device)) { res.getLangOpts().OpenMPIsDevice = 1; + // Get OpenMP host file path if any and report if a non existent file is + // found + if (auto *arg = args.getLastArg( + clang::driver::options::OPT_fopenmp_host_ir_file_path)) { + res.getLangOpts().OMPHostIRFile = arg->getValue(); + if (!llvm::sys::fs::exists(res.getLangOpts().OMPHostIRFile)) + diags.Report(clang::diag::err_drv_omp_host_ir_file_not_found) + << res.getLangOpts().OMPHostIRFile; + } + if (args.hasFlag( clang::driver::options::OPT_fopenmp_assume_teams_oversubscription, clang::driver::options:: -- cgit v1.1