[PATCH] D61855: Simplify SymbolTable::add{Defined,Undefined,...} functions.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 13 06:02:41 PDT 2019


ruiu created this revision.
ruiu added reviewers: grimar, MaskRay, pcc.
Herald added subscribers: dexonsmith, steven_wu, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.

SymbolTable's add-family functions have lots of parameters because
when they have to create a new symbol, they forward given arguments
to Symbol's constructors. Therefore, the functions take at least as
many arguments as their corresponding constructors.

This patch simplifies the add-family functions. Now, the functions
take a symbol instead of arguments to construct a symbol. If there's
no existing symbol, a given symbol is memcpy'ed to the symbol table.
Otherwise, the functions attempt to merge the existing and a given
new symbol.

I also eliminated `CanOmitFromDynSym` parameter, so that the functions
take really one argument.

Symbol classes are trivially constructible, so looks like constructing
them to pass to add-family functions is as cheap as passing a lot of
arguments to the functions. A quick benchmark showed that this patch
seems performance-neutral.

This is a preparation for
http://lists.llvm.org/pipermail/llvm-dev/2019-April/131902.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61855

Files:
  lld/ELF/Driver.cpp
  lld/ELF/InputFiles.cpp
  lld/ELF/LTO.cpp
  lld/ELF/LinkerScript.cpp
  lld/ELF/Relocations.cpp
  lld/ELF/SymbolTable.cpp
  lld/ELF/SymbolTable.h
  lld/ELF/Symbols.cpp
  lld/ELF/Symbols.h
  lld/ELF/Writer.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61855.199259.patch
Type: text/x-patch
Size: 41750 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190513/5c5631ca/attachment-0001.bin>


More information about the llvm-commits mailing list