LoadableByAddress: Add missing BranchInst in a switch

rdar://146980802
This commit is contained in:
Arnold Schwaighofer
2025-03-19 09:26:20 -07:00
parent adc995fb5d
commit 5feb287d19
2 changed files with 29 additions and 0 deletions

View File

@@ -3100,10 +3100,15 @@ void LoadableByAddress::run() {
builtinInstrs.insert(instr);
break;
}
case SILInstructionKind::BranchInst:
case SILInstructionKind::StructInst:
case SILInstructionKind::DebugValueInst:
break;
default:
#ifndef NDEBUG
currInstr->dump();
currInstr->getFunction()->dump();
#endif
llvm_unreachable("Unhandled use of FunctionRefInst");
}
}

View File

@@ -53,3 +53,27 @@ entry(%x : $X):
%retval = tuple ()
return %retval : $()
}
sil @branch_inst_f : $@convention(thin) (@owned X, UInt8) -> ()
sil @branch_inst_f2 : $@convention(thin) (@owned X, UInt8) -> ()
sil @trigger : $@convention(thin) (@owned X) -> ()
// This used to crash.
sil @branch_inst_test : $@convention(thin) (Builtin.Int1, @owned X) -> (@convention(thin) (@owned X, UInt8) -> ()) {
entry(%1 : $Builtin.Int1, %t: $X):
%f = function_ref @trigger : $@convention(thin) (@owned X) -> ()
%x = apply %f(%t) : $@convention(thin) (@owned X) -> ()
cond_br %1, bb1, bb2
bb1:
%2 = function_ref @branch_inst_f : $@convention(thin) (@owned X, UInt8) -> ()
br bb3(%2)
bb2:
%3 = function_ref @branch_inst_f2 : $@convention(thin) (@owned X, UInt8) -> ()
br bb3(%3)
bb3(%r : $@convention(thin) (@owned X, UInt8) -> ()):
return %r : $@convention(thin) (@owned X, UInt8) -> ()
}