Skip to content

Commit ad367dc

Browse files
committed
LLVMTypeAnalyzer: Use isVariableWrite() to check variable writes
1 parent ea7c9b7 commit ad367dc

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/engine/internal/llvm/llvmtypeanalyzer.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Compiler::StaticType LLVMTypeAnalyzer::variableType(LLVMVariablePtr *varPtr, LLV
3636
firstElseBranch = ins;
3737
ins = skipBranch(ins);
3838
continue;
39-
} else if (ins->type == LLVMInstruction::Type::WriteVariable && ins->workVariable == varPtr->var) {
39+
} else if (isVariableWrite(ins, varPtr)) {
4040
if (level <= 0) { // ignore nested branches (they're handled by the branch analyzer)
4141
write = ins;
4242
break;
@@ -141,7 +141,7 @@ Compiler::StaticType LLVMTypeAnalyzer::variableTypeAfterBranchFromEnd(LLVMVariab
141141

142142
ins = skipBranch(ins);
143143
}
144-
} else if (ins->type == LLVMInstruction::Type::WriteVariable && ins->workVariable == varPtr->var) {
144+
} else if (isVariableWrite(ins, varPtr)) {
145145
// Variable write instruction
146146
Compiler::StaticType writeType = writeValueType(ins);
147147
write = true;
@@ -209,6 +209,11 @@ bool LLVMTypeAnalyzer::isIfEnd(LLVMInstruction *ins) const
209209
return (ins->type == LLVMInstruction::Type::EndIf);
210210
}
211211

212+
bool LLVMTypeAnalyzer::isVariableWrite(LLVMInstruction *ins, LLVMVariablePtr *varPtr) const
213+
{
214+
return (ins->type == LLVMInstruction::Type::WriteVariable && ins->workVariable == varPtr->var);
215+
}
216+
212217
Compiler::StaticType LLVMTypeAnalyzer::optimizeRegisterType(LLVMRegister *reg) const
213218
{
214219
// TODO: Move this method out if it's used in LLVMCodeBuilder too

src/engine/internal/llvm/llvmtypeanalyzer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class LLVMTypeAnalyzer
2323
bool isIfStart(LLVMInstruction *ins) const;
2424
bool isElse(LLVMInstruction *ins) const;
2525
bool isIfEnd(LLVMInstruction *ins) const;
26+
bool isVariableWrite(LLVMInstruction *ins, LLVMVariablePtr *varPtr) const;
2627

2728
Compiler::StaticType optimizeRegisterType(LLVMRegister *reg) const;
2829
Compiler::StaticType writeValueType(LLVMInstruction *ins) const;

0 commit comments

Comments
 (0)