summaryrefslogtreecommitdiff
path: root/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
commit2255dc771297ba037ddc83c02acde8937228718b (patch)
treeae010eb727d3f45764243f65412bea56ca6aacd9 /tools/lto
parent00428878bb65cbf2c5620bccda19706cec24c6b9 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212308 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lto')
-rw-r--r--tools/lto/lto.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp
index 5f021244249..8df7315ff79 100644
--- a/tools/lto/lto.cpp
+++ b/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) {