summaryrefslogtreecommitdiffstats
path: root/llvm/lib/LTO
diff options
context:
space:
mode:
authorBen Dunbobbin <bd1976llvm@gmail.com>2019-06-12 11:07:56 +0000
committerBen Dunbobbin <bd1976llvm@gmail.com>2019-06-12 11:07:56 +0000
commit564d248ec2f2a1dc0245ee7942a32fb72e7e1c84 (patch)
treef776b3fa7eab5f6e645330164488d7a08a61128c /llvm/lib/LTO
parentf6efac67e18c5ea66305b2cbc561705eab4ee776 (diff)
downloadbcm5719-llvm-564d248ec2f2a1dc0245ee7942a32fb72e7e1c84.tar.gz
bcm5719-llvm-564d248ec2f2a1dc0245ee7942a32fb72e7e1c84.zip
[ThinLTO]LTO]Legacy] Fix dependent libraries support by adding querying of the IRSymtab
Dependent libraries support for the legacy api was committed in a broken state (see: https://reviews.llvm.org/D60274). This was missed due to the painful nature of having to integrate the changes into a linker in order to test. This change implements support for dependent libraries in the legacy LTO api: - I have removed the current api function, which returns a single string, and added functions to access each dependent library specifier individually. - To reduce the testing pain, I have made the api functions as thin as possible to maximize coverage from llvm-lto. - When doing ThinLTO the system linker will load the modules lazily when scanning the input files. Unfortunately, when modules are lazily loaded there is no access to module level named metadata. To fix this I have added api functions that allow querying the IRSymtab for the dependent libraries. I hope to expand the api in the future so that, eventually, all the information needed by a client linker during scan can be retrieved from the IRSymtab. Differential Revision: https://reviews.llvm.org/D62935 llvm-svn: 363140
Diffstat (limited to 'llvm/lib/LTO')
-rw-r--r--llvm/lib/LTO/LTOModule.cpp32
1 files changed, 27 insertions, 5 deletions
diff --git a/llvm/lib/LTO/LTOModule.cpp b/llvm/lib/LTO/LTOModule.cpp
index 83e9a09854c..a27c78d2595 100644
--- a/llvm/lib/LTO/LTOModule.cpp
+++ b/llvm/lib/LTO/LTOModule.cpp
@@ -645,10 +645,32 @@ void LTOModule::parseMetadata() {
continue;
emitLinkerFlagsForGlobalCOFF(OS, Sym.symbol, TT, M);
}
+}
+
+lto::InputFile *LTOModule::createInputFile(const void *buffer,
+ size_t buffer_size, const char *path,
+ std::string &outErr) {
+ StringRef Data((const char *)buffer, buffer_size);
+ MemoryBufferRef BufferRef(Data, path);
+
+ Expected<std::unique_ptr<lto::InputFile>> ObjOrErr =
+ lto::InputFile::create(BufferRef);
+
+ if (ObjOrErr)
+ return ObjOrErr->release();
+
+ outErr = std::string(path) +
+ ": Could not read LTO input file: " + toString(ObjOrErr.takeError());
+ return nullptr;
+}
+
+size_t LTOModule::getDependentLibraryCount(lto::InputFile *input) {
+ return input->getDependentLibraries().size();
+}
- // Dependent Libraries
- raw_string_ostream OSD(DependentLibraries);
- if (NamedMDNode *DependentLibraries = getModule().getNamedMetadata("llvm.dependent-libraries"))
- for (MDNode *N : DependentLibraries->operands())
- OSD << " " << cast<MDString>(N->getOperand(0))->getString();
+const char *LTOModule::getDependentLibrary(lto::InputFile *input, size_t index,
+ size_t *size) {
+ StringRef S = input->getDependentLibraries()[index];
+ *size = S.size();
+ return S.data();
}
OpenPOWER on IntegriCloud