This is an archive of the discontinued LLVM Phabricator instance.

[gold] Extract runLTO to avoid exit(0) from function with non-trivial objects on the stack
ClosedPublic

Authored by vitalybuka on Feb 20 2018, 4:49 PM.

Details

Summary

exit(0) skips destructors, but we have LTO and dependencies on the stack which may have non trivial ones. E.g. closing files.

Event Timeline

vitalybuka created this revision.Feb 20 2018, 4:49 PM

Can you clarify the motivation for this change - I don't see what is significantly different. The exit(0) for the index-only case is still in the same location and we just end up with a different data structure (Files) on the stack. AFAICT this just trades 2 vectors for a vector of tuples.

vitalybuka edited the summary of this revision. (Show Details)Feb 21 2018, 11:38 AM

Can you clarify the motivation for this change - I don't see what is significantly different. The exit(0) for the index-only case is still in the same location and we just end up with a different data structure (Files) on the stack. AFAICT this just trades 2 vectors for a vector of tuples.

exit(0) skips destructors, but we had LTO and dependencies objects on the stack. Some of them may have or add in the future non trivial destructors. E.g. closing files.
In D43415 I've added local std::unique_ptr<raw_fd_ostream> and it produced empty outputs, because stream was not closed correctly by destructor.

tejohnson accepted this revision.Feb 22 2018, 8:50 AM

LGTM

Thanks for the clarification - I focused on the wrong thing given the change to Filenames/IsTemporary.

This revision is now accepted and ready to land.Feb 22 2018, 8:50 AM
This revision was automatically updated to reflect the committed changes.