aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lto
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-07-23 20:25:01 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-07-23 20:25:01 +0000
commit70c7e485453fdbc228406715556f9447bc9f9fd8 (patch)
tree4125c10ac177c7fde6e17b89be28539ddc3ec486 /tools/lto
parent963cf75e1cf9a87f0f571919d06adcbf60edd377 (diff)
downloadexternal_llvm-70c7e485453fdbc228406715556f9447bc9f9fd8.zip
external_llvm-70c7e485453fdbc228406715556f9447bc9f9fd8.tar.gz
external_llvm-70c7e485453fdbc228406715556f9447bc9f9fd8.tar.bz2
Split getOpenFile into getOpenFile and getOpenFileSlice.
The main observation is that we never need both the filesize and the map size. When mapping a slice of a file, it doesn't make sense to request a null terminator and that would be the only case where the filesize would be used. There are other cleanups that should be done in this area: * A client should not have to pass the size (even an explicit -1) to say if it wants a null terminator or not, so we should probably swap the argument order. * The default should be to not require a null terminator. Very few clients require this, but many end up asking for it just because it is the default. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186984 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lto')
-rw-r--r--tools/lto/LTOModule.cpp7
-rw-r--r--tools/lto/LTOModule.h1
-rw-r--r--tools/lto/lto.cpp3
3 files changed, 4 insertions, 7 deletions
diff --git a/tools/lto/LTOModule.cpp b/tools/lto/LTOModule.cpp
index 5ee43ba..6626eaa 100644
--- a/tools/lto/LTOModule.cpp
+++ b/tools/lto/LTOModule.cpp
@@ -209,17 +209,16 @@ LTOModule *LTOModule::makeLTOModule(const char *path, std::string &errMsg) {
LTOModule *LTOModule::makeLTOModule(int fd, const char *path,
size_t size, std::string &errMsg) {
- return makeLTOModule(fd, path, size, size, 0, errMsg);
+ return makeLTOModule(fd, path, size, 0, errMsg);
}
LTOModule *LTOModule::makeLTOModule(int fd, const char *path,
- size_t file_size,
size_t map_size,
off_t offset,
std::string &errMsg) {
OwningPtr<MemoryBuffer> buffer;
- if (error_code ec = MemoryBuffer::getOpenFile(fd, path, buffer, file_size,
- map_size, offset, false)) {
+ if (error_code ec =
+ MemoryBuffer::getOpenFileSlice(fd, path, buffer, map_size, offset)) {
errMsg = ec.message();
return NULL;
}
diff --git a/tools/lto/LTOModule.h b/tools/lto/LTOModule.h
index 83f3a7d..902e9c5 100644
--- a/tools/lto/LTOModule.h
+++ b/tools/lto/LTOModule.h
@@ -82,7 +82,6 @@ public:
static LTOModule *makeLTOModule(int fd, const char *path,
size_t size, std::string &errMsg);
static LTOModule *makeLTOModule(int fd, const char *path,
- size_t file_size,
size_t map_size,
off_t offset,
std::string& errMsg);
diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp
index 11ad532..e0df81a 100644
--- a/tools/lto/lto.cpp
+++ b/tools/lto/lto.cpp
@@ -78,8 +78,7 @@ lto_module_t lto_module_create_from_fd_at_offset(int fd, const char *path,
size_t file_size,
size_t map_size,
off_t offset) {
- return LTOModule::makeLTOModule(fd, path, file_size, map_size,
- offset, sLastErrorString);
+ return LTOModule::makeLTOModule(fd, path, map_size, offset, sLastErrorString);
}
/// lto_module_create_from_memory - Loads an object file from memory. Returns