summaryrefslogtreecommitdiffstats
path: root/llvm/lib
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/lib
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/lib')
-rw-r--r--llvm/lib/LTO/LTOModule.cpp27
1 files changed, 3 insertions, 24 deletions
diff --git a/llvm/lib/LTO/LTOModule.cpp b/llvm/lib/LTO/LTOModule.cpp
index 6ba99eda219..bdf3ed563d9 100644
--- a/llvm/lib/LTO/LTOModule.cpp
+++ b/llvm/lib/LTO/LTOModule.cpp
@@ -68,30 +68,9 @@ bool LTOModule::isBitcodeFile(const char *path) {
return type == sys::fs::file_magic::bitcode;
}
-/// isBitcodeFileForTarget - Returns 'true' if the file (or memory contents) is
-/// LLVM bitcode for the specified triple.
-bool LTOModule::isBitcodeFileForTarget(const void *mem, size_t length,
- const char *triplePrefix) {
- MemoryBuffer *buffer = makeBuffer(mem, length);
- if (!buffer)
- return false;
- return isTargetMatch(StringRef((const char *)mem, length), triplePrefix);
-}
-
-bool LTOModule::isBitcodeFileForTarget(const char *path,
- const char *triplePrefix) {
- std::unique_ptr<MemoryBuffer> buffer;
- if (MemoryBuffer::getFile(path, buffer))
- return false;
- return isTargetMatch(buffer->getBuffer(), triplePrefix);
-}
-
-/// Returns 'true' if the bitcode BC is for the specified target triple.
-bool LTOModule::isTargetMatch(StringRef BC, const char *TriplePrefix) {
- std::unique_ptr<MemoryBuffer> Buffer(
- MemoryBuffer::getMemBuffer(BC, "", false));
- std::string Triple = getBitcodeTargetTriple(Buffer.get(), getGlobalContext());
- return strncmp(Triple.c_str(), TriplePrefix, strlen(TriplePrefix)) == 0;
+bool LTOModule::isBitcodeForTarget(MemoryBuffer *buffer,
+ StringRef triplePrefix) {
+ return getBitcodeTargetTriple(buffer, getGlobalContext()) == triplePrefix;
}
LTOModule *LTOModule::createFromFile(const char *path, TargetOptions options,
OpenPOWER on IntegriCloud