niyue commented on code in PR #38116:
URL: https://github.com/apache/arrow/pull/38116#discussion_r1364158840


##########
cpp/src/gandiva/engine.cc:
##########
@@ -274,6 +277,27 @@ Status Engine::LoadPreCompiledIR() {
   return Status::OK();
 }
 
+Status Engine::LoadExternalPreCompiledIR() {
+  auto const& buffers = LLVMExternalIRStore::GetIRBuffers();
+  for (auto const& buffer : buffers) {
+    auto module_or_error = llvm::parseBitcodeFile(buffer->getMemBufferRef(), 
*context());
+    if (!module_or_error) {
+      std::string str;
+      llvm::raw_string_ostream stream(str);
+      stream << module_or_error.takeError();
+      return Status::CodeGenError("Failed to parse bitcode file, error: " + 
stream.str());
+    }
+    auto ir_module = std::move(module_or_error.get());
+
+    ARROW_RETURN_IF(llvm::verifyModule(*ir_module, &llvm::errs()),
+                    Status::CodeGenError("verify of IR Module failed"));
+    ARROW_RETURN_IF(llvm::Linker::linkModules(*module_, std::move(ir_module)),
+                    Status::CodeGenError("failed to link IR Modules"));

Review Comment:
   For `llvm::verifyModule`, the parameter `&llvm::errs()` will print the error 
into stdout. Now I change it to a `std::string` backed ` 
llvm::raw_string_ostream`, and return it as part of the `Status`.
   
   For `llvm::Linker::linkModules`, I read the API doc (LLVM 14 in my env), and 
this API only returns a boolean value indicating if an error occurs, but I 
don't find any API to retrieve the detailed error message in this case, so I 
keep it as it is currently.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to