Fix of LLVM codegen for optionals.

This commit is contained in:
Christoffer Lerno
2023-02-17 13:45:16 +01:00
parent baa2e474b5
commit d6a1cecb9d

View File

@@ -1261,11 +1261,13 @@ static void llvm_prune_optional(GenContext *c, LLVMBasicBlockRef discard_fail)
// Optionally remove the comparison
if (!LLVMGetFirstUse(compared))
{
LLVMValueRef operand = NULL;
if (LLVMGetInstructionOpcode(compared) == LLVMCall)
{
LLVMInstructionEraseFromParent(LLVMGetOperand(compared, 0));
operand = LLVMGetOperand(compared, 0);
}
LLVMInstructionEraseFromParent(compared);
if (operand) LLVMInstructionEraseFromParent(operand);
}
// Update the context
c->current_block = prev_block;