Skip to content

Commit b419577

Browse files
committed
LLVMCodeBuilder: Store variable pointer in LLVMVariablePtr
1 parent 0a81319 commit b419577

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/engine/internal/llvm/llvmcodebuilder.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,8 +1448,10 @@ CompilerValue *LLVMCodeBuilder::addVariableValue(Variable *variable)
14481448
auto ins = std::make_shared<LLVMInstruction>(LLVMInstruction::Type::ReadVariable, currentLoopScope(), m_loopCondition);
14491449
ins->workVariable = variable;
14501450

1451-
if (m_variablePtrs.find(variable) == m_variablePtrs.cend())
1451+
if (m_variablePtrs.find(variable) == m_variablePtrs.cend()) {
14521452
m_variablePtrs[variable] = LLVMVariablePtr();
1453+
m_variablePtrs[variable].var = variable;
1454+
}
14531455

14541456
auto ret = std::make_shared<LLVMRegister>(Compiler::StaticType::Unknown);
14551457
ret->isRawValue = false;
@@ -1731,8 +1733,10 @@ void LLVMCodeBuilder::createVariableWrite(Variable *variable, CompilerValue *val
17311733
ins.workVariable = variable;
17321734
createOp(ins, Compiler::StaticType::Void, Compiler::StaticType::Unknown, { value });
17331735

1734-
if (m_variablePtrs.find(variable) == m_variablePtrs.cend())
1736+
if (m_variablePtrs.find(variable) == m_variablePtrs.cend()) {
17351737
m_variablePtrs[variable] = LLVMVariablePtr();
1738+
m_variablePtrs[variable].var = variable;
1739+
}
17361740

17371741
if (m_loopScope >= 0) {
17381742
auto scope = m_loopScopes[m_loopScope];

src/engine/internal/llvm/llvmvariableptr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class LLVMInstruction;
2020

2121
struct LLVMVariablePtr
2222
{
23+
Variable *var = nullptr;
2324
llvm::Value *stackPtr = nullptr;
2425
llvm::Value *heapPtr = nullptr;
2526
Compiler::StaticType type = Compiler::StaticType::Unknown;

0 commit comments

Comments
 (0)