[all-commits] [llvm/llvm-project] 5fc432: [ELF] Change some global pointers to unique_ptr

Fangrui Song via All-commits all-commits at lists.llvm.org
Wed Dec 22 14:36:26 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5fc4323eda60ee15ef4c87d989d468cd0e6d77c1
      https://github.com/llvm/llvm-project/commit/5fc4323eda60ee15ef4c87d989d468cd0e6d77c1
  Author: Fangrui Song <i at maskray.me>
  Date:   2021-12-22 (Wed, 22 Dec 2021)

  Changed paths:
    M lld/ELF/Config.h
    M lld/ELF/Driver.cpp
    M lld/ELF/Driver.h
    M lld/ELF/LinkerScript.cpp
    M lld/ELF/LinkerScript.h
    M lld/ELF/SymbolTable.cpp
    M lld/ELF/SymbolTable.h

  Log Message:
  -----------
  [ELF] Change some global pointers to unique_ptr

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.)

Reviewed By: lichray

Differential Revision: https://reviews.llvm.org/D116143




More information about the All-commits mailing list