This is an archive of the discontinued LLVM Phabricator instance.

[Driver] Use the output filename as the base name in getStatsFileName when -save-stats=obj
AbandonedPublic

Authored by dtcxzyw on Mar 18 2023, 11:32 AM.

Details

Summary

When linking a multi-file program with -save-stats=obj, clang will save internal statistics during the link-time code generation to <obj_dir>/xxx.stats where xxx is the first filename of inputs. This behavior is strange. Additionally, naming conflicts will occur when multiple binaries placed in the same directory depend on the same input (e.g., https://github.com/martinus/map_benchmark).
This patch uses the output filename as the base name instead of the first input when -save-stats=obj.

Diff Detail

Event Timeline

dtcxzyw created this revision.Mar 18 2023, 11:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 18 2023, 11:32 AM
Herald added a subscriber: inglorion. · View Herald Transcript
dtcxzyw requested review of this revision.Mar 18 2023, 11:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 18 2023, 11:32 AM
dtcxzyw updated this revision to Diff 506387.Mar 19 2023, 6:39 AM
dtcxzyw removed subscribers: MaskRay, cfe-commits, inglorion.

Fix test errors.

dtcxzyw updated this revision to Diff 510283.Apr 1 2023, 7:53 PM
dtcxzyw retitled this revision from [Driver] Fix naming conflicts of getStatsFileName when using LTO to [Driver] Use the output filename as the base name in getStatsFileName when -save-stats=obj.
dtcxzyw edited the summary of this revision. (Show Details)
dtcxzyw added reviewers: fhahn, vsapsai, MaskRay.

Add tests

-save-stats=obj behavior seems strange. I think we should port https://maskray.me/blog/2023-04-25-compiler-output-files to -save-stats and deprecated -save-stats=obj.

dtcxzyw abandoned this revision.Mon, Nov 20, 7:37 PM

-save-stats=obj behavior seems strange. I think we should port https://maskray.me/blog/2023-04-25-compiler-output-files to -save-stats and deprecated -save-stats=obj.

I've added "fix -save-stats=obj" to my todo list for the https://maskray.me/blog/2023-04-25-compiler-output-files work I have been doing.