Lunderberg commented on code in PR #14879:
URL: https://github.com/apache/tvm/pull/14879#discussion_r1197966630


##########
src/target/llvm/codegen_cpu.cc:
##########
@@ -466,13 +466,14 @@ llvm::Value* CodeGenCPU::CreateCallExtern(Type ret_type, 
String global_symbol,
   llvm::FunctionType* ftype = llvm::FunctionType::get(GetLLVMType(ret_type), 
arg_types, false);
   // Check if it is available in global function table as injected function.
 
+  llvm::Function* f = module_->getFunction(MakeStringRef(global_symbol));
   auto callee = [&]() -> llvm::Value* {

Review Comment:
   The `callee` was intended to be used in both cases, with the `#if` 
normalizing `callee` into either a `llvm::Value*` or a `llvm::FunctionCallee` 
depending on the LLVM version.  I think we should keep the definition of 
`callee` outside the conditional, but should replace `auto ext_callee = f;` 
with `auto ext_callee = callee;`.  That way, `callee` is initialized as 
appropriate module/context/external function pointer in both branches, and is 
then converted to the type required by the LLVM API inside the directive.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to