Skip to content

Commit c8d6923

Browse files
committed
LLVMCodeBuilder: Store return type in return register
1 parent d8dc2bb commit c8d6923

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/dev/engine/internal/llvm/llvmcodebuilder.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,13 @@ std::shared_ptr<ExecutableCode> LLVMCodeBuilder::finalize()
107107
args.push_back(castValue(arg.second, arg.first));
108108
}
109109

110-
llvm::Value *ret = m_builder.CreateCall(resolveFunction(step.functionName, llvm::FunctionType::get(getType(step.functionReturnType), types, false)), args);
110+
llvm::Type *retType = getType(step.functionReturnReg ? step.functionReturnReg->type : Compiler::StaticType::Void);
111+
llvm::Value *ret = m_builder.CreateCall(resolveFunction(step.functionName, llvm::FunctionType::get(retType, types, false)), args);
111112

112113
if (step.functionReturnReg) {
113114
step.functionReturnReg->value = ret;
114115

115-
if (step.functionReturnType == Compiler::StaticType::String)
116+
if (step.functionReturnReg->type == Compiler::StaticType::String)
116117
m_heap.push_back(step.functionReturnReg->value);
117118
}
118119

@@ -705,8 +706,6 @@ void LLVMCodeBuilder::addFunctionCall(const std::string &functionName, Compiler:
705706

706707
m_tmpRegs.erase(m_tmpRegs.end() - argTypes.size(), m_tmpRegs.end());
707708

708-
ins.functionReturnType = returnType;
709-
710709
if (returnType != Compiler::StaticType::Void) {
711710
auto reg = std::make_shared<LLVMRegister>(returnType);
712711
reg->isRawValue = true;

src/dev/engine/internal/llvm/llvminstruction.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ struct LLVMInstruction
6161
Type type;
6262
std::string functionName;
6363
std::vector<std::pair<Compiler::StaticType, LLVMRegisterPtr>> args; // target type, register
64-
Compiler::StaticType functionReturnType = Compiler::StaticType::Void;
6564
LLVMRegisterPtr functionReturnReg;
6665
Variable *workVariable = nullptr; // for variables
6766
};

0 commit comments

Comments
 (0)