LTO: rename the various makeLTOModule overloads.
authorPeter Collingbourne <peter@pcc.me.uk>
Thu, 3 Jul 2014 23:28:00 +0000 (23:28 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Thu, 3 Jul 2014 23:28:00 +0000 (23:28 +0000)
This rename makes it easier to identify the specific overload being called
in each particular case and makes future refactorings easier.

Differential Revision: http://reviews.llvm.org/D4370

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212302 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/LTO/LTOModule.h
lib/LTO/LTOModule.cpp
tools/gold/gold-plugin.cpp
tools/llvm-lto/llvm-lto.cpp
tools/lto/lto.cpp

index d0674f530cefcc74849f01df2352bfbf2247aa10..46cb034cb6ea3510688cd76b7d974ca01abecf5a 100644 (file)
@@ -86,16 +86,18 @@ public:
   /// InitializeAllTargetMCs();
   /// InitializeAllAsmPrinters();
   /// InitializeAllAsmParsers();
   /// InitializeAllTargetMCs();
   /// InitializeAllAsmPrinters();
   /// InitializeAllAsmParsers();
-  static LTOModule *makeLTOModule(const char *path, TargetOptions options,
-                                  std::string &errMsg);
-  static LTOModule *makeLTOModule(int fd, const char *path, size_t size,
-                                  TargetOptions options, std::string &errMsg);
-  static LTOModule *makeLTOModule(int fd, const char *path, size_t map_size,
-                                  off_t offset, TargetOptions options,
-                                  std::string &errMsg);
-  static LTOModule *makeLTOModule(const void *mem, size_t length,
-                                  TargetOptions options, std::string &errMsg,
-                                  StringRef path = "");
+  static LTOModule *createFromFile(const char *path, TargetOptions options,
+                                   std::string &errMsg);
+  static LTOModule *createFromOpenFile(int fd, const char *path, size_t size,
+                                       TargetOptions options,
+                                       std::string &errMsg);
+  static LTOModule *createFromOpenFileSlice(int fd, const char *path,
+                                            size_t map_size, off_t offset,
+                                            TargetOptions options,
+                                            std::string &errMsg);
+  static LTOModule *createFromBuffer(const void *mem, size_t length,
+                                     TargetOptions options, std::string &errMsg,
+                                     StringRef path = "");
 
   /// Return the Module's target triple.
   const char *getTargetTriple() {
 
   /// Return the Module's target triple.
   const char *getTargetTriple() {
index cda41dcf65daa78437b3c416071823bb3b782975..7d3446ebc177e2159818eb9f0cbcd15a1fc1f086 100644 (file)
@@ -94,10 +94,8 @@ bool LTOModule::isTargetMatch(MemoryBuffer *buffer, const char *triplePrefix) {
   return strncmp(Triple.c_str(), triplePrefix, strlen(triplePrefix)) == 0;
 }
 
   return strncmp(Triple.c_str(), triplePrefix, strlen(triplePrefix)) == 0;
 }
 
-/// makeLTOModule - Create an LTOModule. N.B. These methods take ownership of
-/// the buffer.
-LTOModule *LTOModule::makeLTOModule(const char *path, TargetOptions options,
-                                    std::string &errMsg) {
+LTOModule *LTOModule::createFromFile(const char *path, TargetOptions options,
+                                     std::string &errMsg) {
   std::unique_ptr<MemoryBuffer> buffer;
   if (std::error_code ec = MemoryBuffer::getFile(path, buffer)) {
     errMsg = ec.message();
   std::unique_ptr<MemoryBuffer> buffer;
   if (std::error_code ec = MemoryBuffer::getFile(path, buffer)) {
     errMsg = ec.message();
@@ -106,17 +104,16 @@ LTOModule *LTOModule::makeLTOModule(const char *path, TargetOptions options,
   return makeLTOModule(std::move(buffer), options, errMsg);
 }
 
   return makeLTOModule(std::move(buffer), options, errMsg);
 }
 
-LTOModule *LTOModule::makeLTOModule(int fd, const char *path,
-                                    size_t size, TargetOptions options,
-                                    std::string &errMsg) {
-  return makeLTOModule(fd, path, size, 0, options, errMsg);
+LTOModule *LTOModule::createFromOpenFile(int fd, const char *path, size_t size,
+                                         TargetOptions options,
+                                         std::string &errMsg) {
+  return createFromOpenFileSlice(fd, path, size, 0, options, errMsg);
 }
 
 }
 
-LTOModule *LTOModule::makeLTOModule(int fd, const char *path,
-                                    size_t map_size,
-                                    off_t offset,
-                                    TargetOptions options,
-                                    std::string &errMsg) {
+LTOModule *LTOModule::createFromOpenFileSlice(int fd, const char *path,
+                                              size_t map_size, off_t offset,
+                                              TargetOptions options,
+                                              std::string &errMsg) {
   std::unique_ptr<MemoryBuffer> buffer;
   if (std::error_code ec =
           MemoryBuffer::getOpenFileSlice(fd, path, buffer, map_size, offset)) {
   std::unique_ptr<MemoryBuffer> buffer;
   if (std::error_code ec =
           MemoryBuffer::getOpenFileSlice(fd, path, buffer, map_size, offset)) {
@@ -126,9 +123,9 @@ LTOModule *LTOModule::makeLTOModule(int fd, const char *path,
   return makeLTOModule(std::move(buffer), options, errMsg);
 }
 
   return makeLTOModule(std::move(buffer), options, errMsg);
 }
 
-LTOModule *LTOModule::makeLTOModule(const void *mem, size_t length,
-                                    TargetOptions options,
-                                    std::string &errMsg, StringRef path) {
+LTOModule *LTOModule::createFromBuffer(const void *mem, size_t length,
+                                       TargetOptions options,
+                                       std::string &errMsg, StringRef path) {
   std::unique_ptr<MemoryBuffer> buffer(makeBuffer(mem, length, path));
   if (!buffer)
     return nullptr;
   std::unique_ptr<MemoryBuffer> buffer(makeBuffer(mem, length, path));
   if (!buffer)
     return nullptr;
index c3ae5a6c30b261fcb205acd77010288480099b7f..2c6257a0323cef1b6823e5fb829496e6c57ac70f 100644 (file)
@@ -292,7 +292,7 @@ static ld_plugin_status claim_file_hook(const ld_plugin_input_file *file,
     return LDPS_OK;
 
   std::string Error;
     return LDPS_OK;
 
   std::string Error;
-  M = LTOModule::makeLTOModule(view, file->filesize, TargetOpts, Error);
+  M = LTOModule::createFromBuffer(view, file->filesize, TargetOpts, Error);
   if (!M) {
     (*message)(LDPL_ERROR,
                "LLVM gold plugin has failed to create LTO module: %s",
   if (!M) {
     (*message)(LDPL_ERROR,
                "LLVM gold plugin has failed to create LTO module: %s",
index 8c2d1cdfbb8ea9e1300fea78ec53f9d69fca31a4..8b39f1285f5fcd5702b7761387a90e16e2159644 100644 (file)
@@ -110,7 +110,7 @@ int main(int argc, char **argv) {
   for (unsigned i = BaseArg; i < InputFilenames.size(); ++i) {
     std::string error;
     std::unique_ptr<LTOModule> Module(
   for (unsigned i = BaseArg; i < InputFilenames.size(); ++i) {
     std::string error;
     std::unique_ptr<LTOModule> Module(
-        LTOModule::makeLTOModule(InputFilenames[i].c_str(), Options, error));
+        LTOModule::createFromFile(InputFilenames[i].c_str(), Options, error));
     if (!error.empty()) {
       errs() << argv[0] << ": error loading file '" << InputFilenames[i]
              << "': " << error << "\n";
     if (!error.empty()) {
       errs() << argv[0] << ": error loading file '" << InputFilenames[i]
              << "': " << error << "\n";
index d53d72a52293c6aa009dc1b6e0acc94ef37ce11e..5f021244249e431a0d89689eb22a20208adfe37c 100644 (file)
@@ -104,14 +104,14 @@ lto_module_is_object_file_in_memory_for_target(const void* mem,
 lto_module_t lto_module_create(const char* path) {
   lto_initialize();
   llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
 lto_module_t lto_module_create(const char* path) {
   lto_initialize();
   llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
-  return wrap(LTOModule::makeLTOModule(path, Options, sLastErrorString));
+  return wrap(LTOModule::createFromFile(path, Options, sLastErrorString));
 }
 
 lto_module_t lto_module_create_from_fd(int fd, const char *path, size_t size) {
   lto_initialize();
   llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
   return wrap(
 }
 
 lto_module_t lto_module_create_from_fd(int fd, const char *path, size_t size) {
   lto_initialize();
   llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
   return wrap(
-      LTOModule::makeLTOModule(fd, path, size, Options, sLastErrorString));
+      LTOModule::createFromOpenFile(fd, path, size, Options, sLastErrorString));
 }
 
 lto_module_t lto_module_create_from_fd_at_offset(int fd, const char *path,
 }
 
 lto_module_t lto_module_create_from_fd_at_offset(int fd, const char *path,
@@ -120,14 +120,14 @@ lto_module_t lto_module_create_from_fd_at_offset(int fd, const char *path,
                                                  off_t offset) {
   lto_initialize();
   llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
                                                  off_t offset) {
   lto_initialize();
   llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
-  return wrap(LTOModule::makeLTOModule(fd, path, map_size, offset, Options,
-                                       sLastErrorString));
+  return wrap(LTOModule::createFromOpenFileSlice(fd, path, map_size, offset,
+                                                 Options, sLastErrorString));
 }
 
 lto_module_t lto_module_create_from_memory(const void* mem, size_t length) {
   lto_initialize();
   llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
 }
 
 lto_module_t lto_module_create_from_memory(const void* mem, size_t length) {
   lto_initialize();
   llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
-  return wrap(LTOModule::makeLTOModule(mem, length, Options, sLastErrorString));
+  return wrap(LTOModule::createFromBuffer(mem, length, Options, sLastErrorString));
 }
 
 lto_module_t lto_module_create_from_memory_with_path(const void* mem,
 }
 
 lto_module_t lto_module_create_from_memory_with_path(const void* mem,
@@ -136,7 +136,7 @@ lto_module_t lto_module_create_from_memory_with_path(const void* mem,
   lto_initialize();
   llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
   return wrap(
   lto_initialize();
   llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
   return wrap(
-      LTOModule::makeLTOModule(mem, length, Options, sLastErrorString, path));
+      LTOModule::createFromBuffer(mem, length, Options, sLastErrorString, path));
 }
 
 void lto_module_dispose(lto_module_t mod) { delete unwrap(mod); }
 }
 
 void lto_module_dispose(lto_module_t mod) { delete unwrap(mod); }