Skip to content

Commit 3560360

Browse files
committed
Handle builtin.once in BottomUpFunctionOrder
1 parent 85aa1c1 commit 3560360

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

lib/SILOptimizer/Analysis/FunctionOrder.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,26 @@ void BottomUpFunctionOrder::DFS(SILFunction *Start) {
3939
// Visit all the instructions, looking for apply sites.
4040
for (auto &B : *Start) {
4141
for (auto &I : B) {
42-
auto FAS = FullApplySite::isa(&I);
43-
if (!FAS && !isa<StrongReleaseInst>(&I) && !isa<ReleaseValueInst>(&I) &&
44-
!isa<DestroyValueInst>(&I))
42+
CalleeList callees;
43+
if (auto FAS = FullApplySite::isa(&I)) {
44+
callees = BCA->getCalleeList(FAS);
45+
} else if (isa<StrongReleaseInst>(&I) || isa<ReleaseValueInst>(&I) ||
46+
isa<DestroyValueInst>(&I)) {
47+
callees = BCA->getDestructors(I.getOperand(0)->getType(), /*isExactType*/ false);
48+
} else if (auto *bi = dyn_cast<BuiltinInst>(&I)) {
49+
switch (bi->getBuiltinInfo().ID) {
50+
case BuiltinValueKind::Once:
51+
case BuiltinValueKind::OnceWithContext:
52+
callees = BCA->getCalleeListOfValue(bi->getArguments()[1]);
53+
break;
54+
default:
55+
continue;
56+
}
57+
} else {
4558
continue;
59+
}
4660

47-
auto Callees = FAS ? BCA->getCalleeList(FAS)
48-
: BCA->getDestructors(I.getOperand(0)->getType(),
49-
/*isExactType*/ false);
50-
for (auto *CalleeFn : Callees) {
61+
for (auto *CalleeFn : callees) {
5162
// If not yet visited, visit the callee.
5263
if (DFSNum.find(CalleeFn) == DFSNum.end()) {
5364
DFS(CalleeFn);

0 commit comments

Comments
 (0)