@@ -131,10 +131,11 @@ Compiler::StaticType LLVMTypeAnalyzer::variableTypeAfterBranch(Variable *var, LL
131
131
132
132
// Process the branch from end
133
133
bool write = false ; // only used internally (the compiler doesn't need this)
134
- return variableTypeAfterBranchFromEnd (var, ins , previousType, write, visitedInstructions);
134
+ return typeAfterBranchFromEnd (var, end , previousType, write, visitedInstructions);
135
135
}
136
136
137
- Compiler::StaticType LLVMTypeAnalyzer::variableTypeAfterBranchFromEnd (Variable *var, LLVMInstruction *end, Compiler::StaticType previousType, bool &write, InstructionSet &visitedInstructions) const
137
+ Compiler::StaticType
138
+ LLVMTypeAnalyzer::typeAfterBranchFromEnd (std::variant<Variable *, List *> varOrList, LLVMInstruction *end, Compiler::StaticType previousType, bool &write, InstructionSet &visitedInstructions) const
138
139
{
139
140
// Find the last write instruction
140
141
LLVMInstruction *ins = end->previous ;
@@ -143,7 +144,7 @@ Compiler::StaticType LLVMTypeAnalyzer::variableTypeAfterBranchFromEnd(Variable *
143
144
while (ins && !isLoopStart (ins) && !isIfStart (ins)) {
144
145
if (isLoopEnd (ins) || isIfEnd (ins) || isElse (ins)) {
145
146
// Process the nested loop or if statement
146
- Compiler::StaticType ret = variableTypeAfterBranchFromEnd (var , ins, previousType, write, visitedInstructions);
147
+ Compiler::StaticType ret = typeAfterBranchFromEnd (varOrList , ins, previousType, write, visitedInstructions);
147
148
148
149
if (typesMatch (ret, previousType)) {
149
150
if (write)
@@ -155,7 +156,7 @@ Compiler::StaticType LLVMTypeAnalyzer::variableTypeAfterBranchFromEnd(Variable *
155
156
156
157
if (isElse (ins)) {
157
158
// Process if branch (the else branch is already processed)
158
- ret = variableTypeAfterBranchFromEnd (var , ins, previousType, write, visitedInstructions);
159
+ ret = typeAfterBranchFromEnd (varOrList , ins, previousType, write, visitedInstructions);
159
160
160
161
if (typesMatch (ret, previousType)) {
161
162
if (write) {
@@ -169,7 +170,7 @@ Compiler::StaticType LLVMTypeAnalyzer::variableTypeAfterBranchFromEnd(Variable *
169
170
170
171
ins = skipBranch (ins);
171
172
}
172
- } else if (isVariableWrite (ins, var ) && !isWriteNoOp (ins)) {
173
+ } else if (std::holds_alternative<Variable *>(varOrList), isVariableWrite (ins, std::get<Variable *>(varOrList) ) && !isWriteNoOp (ins)) {
173
174
// Variable write instruction
174
175
Compiler::StaticType writeType = writeValueType (ins, visitedInstructions);
175
176
write = true ;
0 commit comments