summaryrefslogtreecommitdiff
path: root/node/ExprNode.cc
diff options
context:
space:
mode:
authorNagi5Yeq <wu@x-nagi.com>2020-05-30 12:10:38 +0800
committerNagi5Yeq <wu@x-nagi.com>2020-05-30 12:10:38 +0800
commit4c9d2d541c90968db2065260dc94c3be9e8adef9 (patch)
treed9c67d89bb7709bd76ea4809101efbd55dd1a9b0 /node/ExprNode.cc
parent63d2a1c552b0d190a0131c2db2045d154b9ec138 (diff)
use llvm::Function* to call a function for backward compatibility
Diffstat (limited to 'node/ExprNode.cc')
-rw-r--r--node/ExprNode.cc7
1 files changed, 3 insertions, 4 deletions
diff --git a/node/ExprNode.cc b/node/ExprNode.cc
index 93f0068..f4a26a8 100644
--- a/node/ExprNode.cc
+++ b/node/ExprNode.cc
@@ -95,14 +95,13 @@ FunctionCallNode::FunctionCallNode(Context* context, const std::string& name,
Value FunctionCallNode::CodeGen() {
TypeManager* manager = context_->GetTypeManager();
- std::shared_ptr<FunctionType> type = context_->GetFunctionType(name_);
+ Function function = context_->FindFunction(name_);
+ std::shared_ptr<FunctionType> type = std::get<0>(function);
if (type == nullptr) {
Log(LogLevel::PCC_ERROR, "call to undefined function %s",
name_.c_str());
return nullptr;
}
- llvm::FunctionCallee fp = context_->GetModule()->getOrInsertFunction(
- name_, llvm::cast<llvm::FunctionType>(type->GetLLVMType()));
const std::vector<std::shared_ptr<Type>>& ArgTypes = type->GetArgTypes();
std::vector<Value> ArgValues(args_.size());
auto ArgTypeIt = ArgTypes.begin();
@@ -121,6 +120,6 @@ Value FunctionCallNode::CodeGen() {
++ArgTypeIt, ++ArgValueIt;
}
type_ = type->GetReturnType();
- return context_->GetBuilder()->CreateCall(fp, ArgValues);
+ return context_->GetBuilder()->CreateCall(std::get<1>(function), ArgValues);
}
} // namespace pcc