[PATCH] D136769: [LTO] Fix lto_module_create_in_codegen_context return value on error

Steven Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 26 08:56:28 PDT 2022


steven_wu created this revision.
steven_wu added a reviewer: tejohnson.
Herald added subscribers: ormris, ributzka, hiraditya, inglorion.
Herald added a project: All.
steven_wu requested review of this revision.
Herald added a project: LLVM.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136769

Files:
  llvm/tools/lto/lto.cpp


Index: llvm/tools/lto/lto.cpp
===================================================================
--- llvm/tools/lto/lto.cpp
+++ llvm/tools/lto/lto.cpp
@@ -290,6 +290,8 @@
       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());
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136769.470826.patch
Type: text/x-patch
Size: 445 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221026/ba680a54/attachment.bin>


More information about the llvm-commits mailing list