diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp index d68cff839604f6..c8fbbd1e0b24b7 100644 --- a/llvm/tools/lto/lto.cpp +++ b/llvm/tools/lto/lto.cpp @@ -13,6 +13,7 @@ #include "llvm-c/lto.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Bitcode/BitcodeReader.h" #include "llvm/CodeGen/CommandFlags.h" @@ -88,6 +89,8 @@ struct LTOToolDiagnosticHandler : public DiagnosticHandler { } }; +static SmallVector RuntimeLibcallSymbols; + // Initialize the configured targets if they have not been initialized. static void lto_initialize() { if (!initialized) { @@ -108,6 +111,7 @@ static void lto_initialize() { LTOContext = &Context; LTOContext->setDiagnosticHandler( std::make_unique(), true); + RuntimeLibcallSymbols = lto::LTO::getRuntimeLibcallSymbols(Triple()); initialized = true; } } @@ -691,7 +695,6 @@ extern const char *lto_input_get_dependent_library(lto_input_t input, } extern const char *const *lto_runtime_lib_symbols_list(size_t *size) { - auto symbols = lto::LTO::getRuntimeLibcallSymbols(Triple()); - *size = symbols.size(); - return symbols.data(); + *size = RuntimeLibcallSymbols.size(); + return RuntimeLibcallSymbols.data(); }