This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Simplify adding default atoms
ClosedPublic

Authored by atanasyan on Apr 6 2015, 10:50 PM.

Details

Summary

Now 'writer' creates an instance of RuntimeFile in the constructor, then populates the file in the virtual function addDefaultAtoms, then pass owning of this file to the caller of virtual function createImplicitFiles.

First, we do not need to keep an instance of RuntimeFile so long. It is enough to create the file, right after that populate it and pass the owning.

Second, relationship between createImplicitFiles and addDefaultAtoms is complicated. The createImplicitFiles might call addDefaultAtoms, overridden version of addDefaultAtoms might call base class addDefaultAtoms, and overridden version of createImplicitFiles might call base class createImplicitFiles as well as addDefaultAtoms.

The patch solves both problems above. It creates and populates runtime files right in the createImplicitFiles(), removes addDefaultAtoms at all and does not keep references to runtime files in class fields.

Diff Detail

Repository
rL LLVM

Event Timeline

atanasyan updated this revision to Diff 23309.Apr 6 2015, 10:50 PM
atanasyan retitled this revision from to [ELF] Simplify adding default atoms.
atanasyan updated this object.
atanasyan edited the test plan for this revision. (Show Details)
atanasyan set the repository for this revision to rL LLVM.
atanasyan added a project: lld.
atanasyan added a subscriber: Unknown Object (MLST).
shankar.easwaran edited edge metadata.

LGTM

This revision is now accepted and ready to land.Apr 7 2015, 7:11 AM
ruiu accepted this revision.Apr 7 2015, 9:14 AM
ruiu edited edge metadata.

Thank you for doing this. This is a nice cleanup. LGTM.

lib/ReaderWriter/ELF/DynamicLibraryWriter.h
64

addAbsoluteAtom returns a pointer to a new atom, so we discard the pointer here. Looks like we don't use return values from the function at all. This doesn't have to be done in this patch, but we should make the function return void.

atanasyan closed this revision.Apr 7 2015, 1:34 PM

Thanks for review.

Closed by commit rL234347.