This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Change some global pointers to unique_ptr
ClosedPublic

Authored by MaskRay on Dec 21 2021, 10:57 PM.

Details

Summary

Currently the singleton config is assigned by config = make<Configuration>()
and (if canExitEarly is false) destroyed by lld::freeArena.

make<Configuration> allocates a stab with malloc(4096). This both wastes
memory and bloats the executable (every type instantiates BumpPtrAllocator
which costs more than 1KiB code on x86-64).

(No need to worry about clang::no_destroy. Regular invocations (canExitEarly
is true) call _Exit (via llvm::sys::Process::ExitNoCleanup).)

Diff Detail

Event Timeline

MaskRay created this revision.Dec 21 2021, 10:57 PM
MaskRay requested review of this revision.Dec 21 2021, 10:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 21 2021, 10:57 PM

Looks reasonable to me.

lichray accepted this revision.Dec 22 2021, 12:14 PM
This revision is now accepted and ready to land.Dec 22 2021, 12:14 PM

I'll push now as the benefit is obvious enough.

MaskRay edited the summary of this revision. (Show Details)Dec 22 2021, 2:34 PM
This revision was automatically updated to reflect the committed changes.