This is an archive of the discontinued LLVM Phabricator instance.

[Flang] Add main-file-name flag to flang -fc1
AbandonedPublic

Authored by domada on May 25 2023, 7:05 AM.

Details

Summary

Flag main-file-name is used to store information about original input file. Information about original input file is used for:

  1. Determining the name of offload function for omp target pragma
  2. Providing information about original input Fortran file for *mlir files and *.bc files

Diff Detail

Event Timeline

domada created this revision.May 25 2023, 7:05 AM
Herald added a reviewer: ftynse. · View Herald Transcript
Herald added a reviewer: dcaballe. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
domada requested review of this revision.May 25 2023, 7:05 AM

You should be able to get this information from the source location in MLIR.

You should be able to get this information from the source location in MLIR.

Hi, thank you for your quick feedback.

You are right, the source location is provided in MLIR. Unfortunately, when we compile the source code with -save-temps file, then we use preprocessed file as the input for MLIR and we have no information about original source file.

Please look at the output of the command:
flang-new -save-temps -v **test.f90**

Output:
flang-new -fc1 /*some fc1 options */ **-o test.i test.f90**
flang-new -fc1 /*some fc1 options */ **-o test.bc test.i**

If we generate the code for OpenMP, then we generate two different preprocessed files (one for host code, the second one for the device). Then we use these preprocessed files as the input for MLIR. Originally we use the name of preprocessed file as the input for generation of unique name of OpenMP kernel function (please look at the original code inside mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp ). In consequence we generate two different kernel names for host and the device module (host and the device code should operate on the same name of the kernel function). To fix that isssue I provide an information about the original source file (not the name of the input preprocessed file).

domada updated this revision to Diff 532588.Jun 19 2023, 3:43 AM
domada edited the summary of this revision. (Show Details)

Patch rebased.

Detailed discussion about the need of introduction of the new flag can be found on LLVM discourse

domada abandoned this revision.Jun 29 2023, 4:24 AM

Patch not needed. Preprocessor change: https://reviews.llvm.org/D153910 enables passing information about original source file.