summaryrefslogtreecommitdiffstats
path: root/llvm/tools/lto
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2014-07-04 00:58:41 +0000
committerAlp Toker <alp@nuanti.com>2014-07-04 00:58:41 +0000
commitac90380b5e9ef1c4fa32ab0bee869a0be5ddbea2 (patch)
tree913bfcdf5c59c27b44a2bf2bd1c706a6fb15958a /llvm/tools/lto
parent651ed5e8fdf05878088b2f7579735083775e43e3 (diff)
downloadbcm5719-llvm-ac90380b5e9ef1c4fa32ab0bee869a0be5ddbea2.tar.gz
bcm5719-llvm-ac90380b5e9ef1c4fa32ab0bee869a0be5ddbea2.zip
Sink undesirable LTO functions into the old C API
We want to encourage users of the C++ LTO API to reuse memory buffers instead of repeatedly opening and reading the same file contents. This reverts commit r212305 and implements a tidier scheme. llvm-svn: 212308
Diffstat (limited to 'llvm/tools/lto')
-rw-r--r--llvm/tools/lto/lto.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp
index 5f021244249..8df7315ff79 100644
--- a/llvm/tools/lto/lto.cpp
+++ b/llvm/tools/lto/lto.cpp
@@ -16,6 +16,7 @@
#include "llvm/CodeGen/CommandFlags.h"
#include "llvm/LTO/LTOCodeGenerator.h"
#include "llvm/LTO/LTOModule.h"
+#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/TargetSelect.h"
// extra command-line flags needed for LTOCodeGenerator
@@ -87,7 +88,10 @@ bool lto_module_is_object_file(const char* path) {
bool lto_module_is_object_file_for_target(const char* path,
const char* target_triplet_prefix) {
- return LTOModule::isBitcodeFileForTarget(path, target_triplet_prefix);
+ std::unique_ptr<MemoryBuffer> buffer;
+ if (MemoryBuffer::getFile(path, buffer))
+ return false;
+ return LTOModule::isBitcodeForTarget(buffer.get(), target_triplet_prefix);
}
bool lto_module_is_object_file_in_memory(const void* mem, size_t length) {
@@ -98,7 +102,10 @@ bool
lto_module_is_object_file_in_memory_for_target(const void* mem,
size_t length,
const char* target_triplet_prefix) {
- return LTOModule::isBitcodeFileForTarget(mem, length, target_triplet_prefix);
+ std::unique_ptr<MemoryBuffer> buffer(LTOModule::makeBuffer(mem, length));
+ if (!buffer)
+ return false;
+ return LTOModule::isBitcodeForTarget(buffer.get(), target_triplet_prefix);
}
lto_module_t lto_module_create(const char* path) {
OpenPOWER on IntegriCloud