[llvm] 76ebaf2 - [LTO] Fix lto_module_create_in_codegen_context return value on error

Steven Wu via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 26 15:15:04 PDT 2022


Author: Steven Wu
Date: 2022-10-26T15:13:22-07:00
New Revision: 76ebaf263b20619b3416fbaa715fea25735bfe30

URL: https://github.com/llvm/llvm-project/commit/76ebaf263b20619b3416fbaa715fea25735bfe30
DIFF: https://github.com/llvm/llvm-project/commit/76ebaf263b20619b3416fbaa715fea25735bfe30.diff

LOG: [LTO] Fix lto_module_create_in_codegen_context return value on error

According to the documentation, lto_module_create_in_codegen_context
should return NULL on error but currently it is accidentally return
error_code. Since this is a bug fix and it seems to be a one-off bug
that only affects this API, there is no need to bump API version.

rdar://101505192

Reviewed By: pete

Differential Revision: https://reviews.llvm.org/D136769

Added: 
    

Modified: 
    llvm/tools/lto/lto.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp
index ff5c2c6c1a374..1402565e27cf1 100644
--- a/llvm/tools/lto/lto.cpp
+++ b/llvm/tools/lto/lto.cpp
@@ -290,6 +290,8 @@ lto_module_t lto_module_create_in_codegen_context(const void *mem,
       codegen::InitTargetOptionsFromCodeGenFlags(Triple());
   ErrorOr<std::unique_ptr<LTOModule>> M = LTOModule::createFromBuffer(
       unwrap(cg)->getContext(), mem, length, Options, StringRef(path));
+  if (!M)
+    return nullptr;
   return wrap(M->release());
 }
 


        


More information about the llvm-commits mailing list