| 531 | } |
| 532 | |
| 533 | llvm::Value* LLVMGenerator::AddFunctionCall(const std::string& full_name, |
| 534 | llvm::Type* ret_type, |
| 535 | const std::vector<llvm::Value*>& args) { |
| 536 | // find the llvm function. |
| 537 | llvm::Function* fn = module()->getFunction(full_name); |
| 538 | DCHECK_NE(fn, nullptr) << "missing function " << full_name; |
| 539 | |
| 540 | if (enable_ir_traces_ && !full_name.compare("printf") && |
| 541 | !full_name.compare("printff")) { |
| 542 | // Trace for debugging |
| 543 | ADD_TRACE("invoke native fn " + full_name); |
| 544 | } |
| 545 | |
| 546 | // build a call to the llvm function. |
| 547 | llvm::CallInst* call; |
| 548 | if (ret_type->isVoidTy()) { |
| 549 | // void functions can't have a name for the call. |
| 550 | call = ir_builder()->CreateCall(fn, args); |
| 551 | } else { |
| 552 | call = ir_builder()->CreateCall(fn, args, full_name); |
| 553 | DCHECK(call->getType() == ret_type); |
| 554 | } |
| 555 | internal::CopyZExtAttrs(*fn, *call); |
| 556 | |
| 557 | return call; |
| 558 | } |
| 559 | |
| 560 | std::shared_ptr<DecimalLValue> LLVMGenerator::BuildDecimalLValue(llvm::Value* value, |
| 561 | DataTypePtr arrow_type) { |