[flang-commits] [flang] [flang] Remove hardcoded bits from AddDebugInfo. (PR #89231)
via flang-commits
flang-commits at lists.llvm.org
Fri Apr 19 04:13:26 PDT 2024
================
@@ -52,21 +55,40 @@ void AddDebugInfoPass::runOnOperation() {
mlir::ModuleOp module = getOperation();
mlir::MLIRContext *context = &getContext();
mlir::OpBuilder builder(context);
- std::string inputFilePath("-");
- if (auto fileLoc = module.getLoc().dyn_cast<mlir::FileLineColLoc>())
- inputFilePath = fileLoc.getFilename().getValue();
+ llvm::StringRef fileName;
+ std::string filePath;
+ // We need 2 type of file paths here.
+ // 1. Name of the file as was presented to compiler. This can be absolute
+ // or relative to 2.
+ // 2. Current working directory
+ //
+ // We are also dealing with 2 different situations below. One is normal
+ // compilation where we will have a value in 'inputFilename' and we can
+ // obtain the current directory using 'current_path'.
+ // The 2nd case is when this pass is invoked directly from 'fir-opt' tool.
+ // In that case, 'inputFilename' may be empty. Location embedded in the
+ // module will be used to get file name and its directory.
----------------
abidh wrote:
In ideal case, we would like it to be the current working directory as I explained above. But we don't have that information in 2nd case so using parent directory is sort of a compromise.
https://github.com/llvm/llvm-project/pull/89231
More information about the flang-commits
mailing list