This is an archive of the discontinued LLVM Phabricator instance.

[Flang][Debug] Use pathnames from location of functions
ClosedPublic

Authored by kiranchandramohan on Jan 20 2023, 4:06 PM.

Details

Summary

This ensures that functions in included files have the correct path
in their file metadata.

Note: This patch also sets all locations to have the full path names.

Diff Detail

Event Timeline

Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
kiranchandramohan requested review of this revision.Jan 20 2023, 4:06 PM

Add comments in test files.

Address comments from @vzakhari/@jeanPerier in D137956.

flang/lib/Lower/Bridge.cpp
714

Note: This change will convert all paths to absolute paths in location information.

PeteSteinfeld accepted this revision.Jan 23 2023, 7:32 AM

All builds and tests correctly and looks good.

This revision is now accepted and ready to land.Jan 23 2023, 7:32 AM
vzakhari added inline comments.Jan 23 2023, 6:16 PM
flang/lib/Lower/Bridge.cpp
712

I see that clang checks for - input in some case before trying to make the path absolute - I wonder if we need to handle the stdin here.

flang/lib/Optimizer/Transforms/AddDebugFoundation.cpp
64

nit: I think the additional hashing is excessive, because the attributes should be hashed already.

flang/test/Transforms/debug-line-table-inc-file.fir
28

nit: as written, [[FILE]] and [[INC_FILE]] may match to the same file name. A more robust checking criteria should be using parts of the original file names.

Address comments from @vzakhari.

flang/lib/Lower/Bridge.cpp
712

Thanks for bringing up this point. I think we need some special handling for stdin. I would have to look into this in a bit more detail before handling it. Would it be OK to handle this in a follow-up patch? I can create a ticket for this.

I see the following:
-> Clang seems to have both - and <stdin>.
-> MLIR seems to be using <stdin>.
-> Flang frontend seems to be passing standard input as filename.
-> Gfortran uses <stdin>

flang/lib/Optimizer/Transforms/AddDebugFoundation.cpp
64

Good point.

flang/test/Transforms/debug-line-table-inc-file.fir
28

Using the file name now.

vzakhari accepted this revision.Jan 24 2023, 4:39 PM

Thank you for the updates! LGTM

flang/lib/Lower/Bridge.cpp
712

Thank you for looking it up, Kiran! Yes, it is okay to handle it seprately. A ticket would be good.