Skip to content

Commit 4688929

Browse files
Merge pull request #80124 from aschwaighofer/loadable_by_address_branch_inst
LoadableByAddress: Add missing BranchInst in a switch
2 parents 37db1af + 5feb287 commit 4688929

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

lib/IRGen/LoadableByAddress.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -3100,10 +3100,15 @@ void LoadableByAddress::run() {
31003100
builtinInstrs.insert(instr);
31013101
break;
31023102
}
3103+
case SILInstructionKind::BranchInst:
31033104
case SILInstructionKind::StructInst:
31043105
case SILInstructionKind::DebugValueInst:
31053106
break;
31063107
default:
3108+
#ifndef NDEBUG
3109+
currInstr->dump();
3110+
currInstr->getFunction()->dump();
3111+
#endif
31073112
llvm_unreachable("Unhandled use of FunctionRefInst");
31083113
}
31093114
}

test/IRGen/loadable_by_address.sil

+24
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,27 @@ entry(%x : $X):
5353
%retval = tuple ()
5454
return %retval : $()
5555
}
56+
57+
sil @branch_inst_f : $@convention(thin) (@owned X, UInt8) -> ()
58+
sil @branch_inst_f2 : $@convention(thin) (@owned X, UInt8) -> ()
59+
60+
sil @trigger : $@convention(thin) (@owned X) -> ()
61+
62+
// This used to crash.
63+
sil @branch_inst_test : $@convention(thin) (Builtin.Int1, @owned X) -> (@convention(thin) (@owned X, UInt8) -> ()) {
64+
entry(%1 : $Builtin.Int1, %t: $X):
65+
%f = function_ref @trigger : $@convention(thin) (@owned X) -> ()
66+
%x = apply %f(%t) : $@convention(thin) (@owned X) -> ()
67+
cond_br %1, bb1, bb2
68+
69+
bb1:
70+
%2 = function_ref @branch_inst_f : $@convention(thin) (@owned X, UInt8) -> ()
71+
br bb3(%2)
72+
73+
bb2:
74+
%3 = function_ref @branch_inst_f2 : $@convention(thin) (@owned X, UInt8) -> ()
75+
br bb3(%3)
76+
77+
bb3(%r : $@convention(thin) (@owned X, UInt8) -> ()):
78+
return %r : $@convention(thin) (@owned X, UInt8) -> ()
79+
}

0 commit comments

Comments
 (0)