summaryrefslogtreecommitdiffstats
path: root/llvm/lib/LTO
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2014-07-03 23:49:28 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2014-07-03 23:49:28 +0000
commitd7f75eeffc289dcb877dea8cf4fafaef8e3c46e9 (patch)
treef42dd505e2557d7e1c88fe737f5e7d60a19f3a5a /llvm/lib/LTO
parent35974065fe363151307b95d50083a2cf6ebe919c (diff)
downloadbcm5719-llvm-d7f75eeffc289dcb877dea8cf4fafaef8e3c46e9.tar.gz
bcm5719-llvm-d7f75eeffc289dcb877dea8cf4fafaef8e3c46e9.zip
Modify LTOModule::isTargetMatch to take a StringRef instead of a MemoryBuffer.
llvm-svn: 212305
Diffstat (limited to 'llvm/lib/LTO')
-rw-r--r--llvm/lib/LTO/LTOModule.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/llvm/lib/LTO/LTOModule.cpp b/llvm/lib/LTO/LTOModule.cpp
index 7d3446ebc17..6ba99eda219 100644
--- a/llvm/lib/LTO/LTOModule.cpp
+++ b/llvm/lib/LTO/LTOModule.cpp
@@ -75,7 +75,7 @@ bool LTOModule::isBitcodeFileForTarget(const void *mem, size_t length,
MemoryBuffer *buffer = makeBuffer(mem, length);
if (!buffer)
return false;
- return isTargetMatch(buffer, triplePrefix);
+ return isTargetMatch(StringRef((const char *)mem, length), triplePrefix);
}
bool LTOModule::isBitcodeFileForTarget(const char *path,
@@ -83,15 +83,15 @@ bool LTOModule::isBitcodeFileForTarget(const char *path,
std::unique_ptr<MemoryBuffer> buffer;
if (MemoryBuffer::getFile(path, buffer))
return false;
- return isTargetMatch(buffer.release(), triplePrefix);
+ return isTargetMatch(buffer->getBuffer(), triplePrefix);
}
-/// isTargetMatch - Returns 'true' if the memory buffer is for the specified
-/// target triple.
-bool LTOModule::isTargetMatch(MemoryBuffer *buffer, const char *triplePrefix) {
- std::string Triple = getBitcodeTargetTriple(buffer, getGlobalContext());
- delete buffer;
- return strncmp(Triple.c_str(), triplePrefix, strlen(triplePrefix)) == 0;
+/// 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;
}
LTOModule *LTOModule::createFromFile(const char *path, TargetOptions options,
OpenPOWER on IntegriCloud