This is an archive of the discontinued LLVM Phabricator instance.

Fix -ftime-report with -x ir
Needs ReviewPublic

Authored by arsenm on Feb 6 2019, 12:09 PM.

Details

Summary

This was only printing the clang frontend timer, and none of the
backend timers. Set the llvm global for enabling the backend time
report when creating the frontend timers, rather than in the
BackendConsumer constructor.

There's still something wrong with how the timers are managed though,
since the report seems to be printed twice for each one.

Diff Detail

Event Timeline

arsenm created this revision.Feb 6 2019, 12:09 PM

I partially solved the problem with double printing the reports. It's from this in cc1_main:

// If any timers were active but haven't been destroyed yet, print theirp
// results now.  This happens in -disable-free mode.
llvm::TimerGroup::printAll(llvm::errs());

On a source file, -ftime-report -disable-free prints one report. -ftime-report without disable-free prints 2. For the IR file, both happen either way and it double prints. The printing destructor can still be called from the ManagedStatic in PassTimingInfo

I partially solved the problem with double printing the reports. It's from this in cc1_main:

// If any timers were active but haven't been destroyed yet, print theirp
// results now.  This happens in -disable-free mode.
llvm::TimerGroup::printAll(llvm::errs());

On a source file, -ftime-report -disable-free prints one report. -ftime-report without disable-free prints 2. For the IR file, both happen either way and it double prints. The printing destructor can still be called from the ManagedStatic in PassTimingInfo

I dont quite understand what clang is doing in terms of timers (and what -disable-free is/how does it interact with -ftime-report).
However if after doing printAll() you expect that there wont be any other reports then you should call clearAll() immediately after.

fedor.sergeev added inline comments.Mar 15 2019, 3:27 PM
test/Frontend/ftime-report-bitcode.ll
1

Can you, please, test -fexperimental-new-pass-manager mode as well?
Implementation of time-passes is different between legacy and newpm.

fedor.sergeev requested changes to this revision.Mar 28 2019, 4:45 AM

just to make the comments visible :)

This revision now requires changes to proceed.Mar 28 2019, 4:45 AM
arsenm updated this revision to Diff 255095.Apr 4 2020, 7:24 PM

Rebase, add new PM run line