This is an archive of the discontinued LLVM Phabricator instance.

Simplify InputFile ownership management.
ClosedPublic

Authored by ruiu on Sep 12 2016, 10:19 PM.

Details

Summary

Previously, all input files were owned by the symbol table.
Files were created at various places, such as the Driver, the lazy
symbols, or the bitcode compiler, and the ownership of new files
was transferred to the symbol table using std::unique_ptr.
All input files were then free'd when the symbol table is freed
which is on program exit.

I think we don't have to transfer ownership just to free all
instance at once on exit.

In this patch, all instances are automatically collected to a
vector and freed on exit. In this way, we no longer have to
use std::unique_ptr.

Diff Detail

Repository
rL LLVM

Event Timeline

ruiu updated this revision to Diff 71108.Sep 12 2016, 10:19 PM
ruiu retitled this revision from to Simplify InputFile ownership management..
ruiu updated this object.
ruiu added a reviewer: rafael.
ruiu added a subscriber: llvm-commits.
rafael accepted this revision.Sep 13 2016, 10:57 AM
rafael edited edge metadata.

LGTM with a suggestion for a further simplification if possible.

ELF/InputFiles.cpp
39 ↗(On Diff #71108)

Do we actually have that requirement?

If not, the Pool could just contain std::unique_ptr and this function could be deleted.

This revision is now accepted and ready to land.Sep 13 2016, 10:57 AM
ruiu added a comment.Sep 13 2016, 11:24 AM

I didn't look into details, but a LTO test failed without this deterministic destruction, so I assume it's needed.

davide added a subscriber: davide.Sep 13 2016, 11:57 AM

Can I please ask you to hold on this until https://reviews.llvm.org/D24492 lands? (should happen soon). This will avoid me a little bit of merge pain.

ruiu added a comment.Sep 13 2016, 5:11 PM

Davide,

Is https://reviews.llvm.org/D24492 going to be submitted soon? I think there shouldn't be many conflicts with this patch (you basically have to change std::unique_ptr with regualar * and that's it.) If it takes more than a day, I'd like to submit this first.

In D24493#541956, @ruiu wrote:

Davide,

Is https://reviews.llvm.org/D24492 going to be submitted soon? I think there shouldn't be many conflicts with this patch (you basically have to change std::unique_ptr with regualar * and that's it.) If it takes more than a day, I'd like to submit this first.

Still working on it. Please submit.

This revision was automatically updated to reflect the committed changes.