Skip to content

Commit dd63b9f

Browse files
[lld] Update lld driver to use new LTO APIs to handle libcall symbols
NFC. Remove duplicated code in ELF/COFF driver and libLTO legacy interfaces. llvm-svn: 372022
1 parent 34d8046 commit dd63b9f

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

lld/COFF/Driver.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "llvm/ADT/Optional.h"
2828
#include "llvm/ADT/StringSwitch.h"
2929
#include "llvm/BinaryFormat/Magic.h"
30+
#include "llvm/LTO/LTO.h"
3031
#include "llvm/Object/ArchiveWriter.h"
3132
#include "llvm/Object/COFFImportFile.h"
3233
#include "llvm/Object/COFFModuleDefinition.h"
@@ -1070,12 +1071,6 @@ void LinkerDriver::maybeExportMinGWSymbols(const opt::InputArgList &args) {
10701071
});
10711072
}
10721073

1073-
static const char *libcallRoutineNames[] = {
1074-
#define HANDLE_LIBCALL(code, name) name,
1075-
#include "llvm/IR/RuntimeLibcalls.def"
1076-
#undef HANDLE_LIBCALL
1077-
};
1078-
10791074
void LinkerDriver::link(ArrayRef<const char *> argsArr) {
10801075
// Needed for LTO.
10811076
InitializeAllTargetInfos();
@@ -1804,7 +1799,7 @@ void LinkerDriver::link(ArrayRef<const char *> argsArr) {
18041799
// bitcode file in an archive member, we need to arrange to use LTO to
18051800
// compile those archive members by adding them to the link beforehand.
18061801
if (!BitcodeFile::instances.empty())
1807-
for (const char *s : libcallRoutineNames)
1802+
for (auto *s : lto::LTO::getRuntimeLibcallSymbols())
18081803
symtab->addLibcall(s);
18091804

18101805
// Windows specific -- if __load_config_used can be resolved, resolve it.

lld/ELF/Driver.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "llvm/ADT/SetVector.h"
4949
#include "llvm/ADT/StringExtras.h"
5050
#include "llvm/ADT/StringSwitch.h"
51+
#include "llvm/LTO/LTO.h"
5152
#include "llvm/Support/CommandLine.h"
5253
#include "llvm/Support/Compression.h"
5354
#include "llvm/Support/GlobPattern.h"
@@ -1672,12 +1673,6 @@ template <class ELFT> static uint32_t getAndFeatures() {
16721673
return ret;
16731674
}
16741675

1675-
static const char *libcallRoutineNames[] = {
1676-
#define HANDLE_LIBCALL(code, name) name,
1677-
#include "llvm/IR/RuntimeLibcalls.def"
1678-
#undef HANDLE_LIBCALL
1679-
};
1680-
16811676
// Do actual linking. Note that when this function is called,
16821677
// all linker scripts have already been parsed.
16831678
template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
@@ -1768,7 +1763,7 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
17681763
// libcall symbols will be added to the link after LTO when we add the LTO
17691764
// object file to the link.
17701765
if (!bitcodeFiles.empty())
1771-
for (const char *s : libcallRoutineNames)
1766+
for (auto *s : lto::LTO::getRuntimeLibcallSymbols())
17721767
handleLibcall(s);
17731768

17741769
// Return if there were name resolution errors.

0 commit comments

Comments
 (0)