Skip to content

Commit b232357

Browse files
committed
Fix SSA values array sizing using dynamic resize in LLVM backend
1 parent f19f59b commit b232357

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/compiler/backend_llvm.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ class LLVMEmitter {
131131
llvm::Function *F = llvm::Function::Create(FT, llvm::Function::ExternalLinkage, func->name, ModuleOb.get());
132132

133133
ssaValues.clear();
134-
ssaValues.resize(func->nextSsaVal + 2048, nullptr);
135134
blockMap.clear();
136135

137136
// Pass 1: Create all blocks
@@ -307,6 +306,9 @@ class LLVMEmitter {
307306
}
308307

309308
void emitInstruction(IRInstruction* instr, llvm::Value* CoroHdl = nullptr) {
309+
if (instr->result >= 0 && instr->result >= (int)ssaValues.size()) {
310+
ssaValues.resize(instr->result + 256, nullptr);
311+
}
310312
switch (instr->opcode) {
311313
case IR_OP_CONST: {
312314
llvm::Value* v = nullptr;

0 commit comments

Comments
 (0)