Skip to content

Commit 559c61c

Browse files
committed
Fix isTriviallyDuplicatable to handle open_pack_element
SILInstruction::clone doesn't know how to clone instructions that produce the archetype uuid. SILCloner is equipped to handle such instructions. Optimizations like LoopRotate use SILInstruction::clone and will be incorrect for such instructions. rdar://130047619
1 parent e4566c8 commit 559c61c

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lib/SIL/IR/SILInstruction.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,8 +1418,10 @@ bool SILInstruction::isTriviallyDuplicatable() const {
14181418

14191419
if (isa<OpenExistentialAddrInst>(this) || isa<OpenExistentialRefInst>(this) ||
14201420
isa<OpenExistentialMetatypeInst>(this) ||
1421-
isa<OpenExistentialValueInst>(this) || isa<OpenExistentialBoxInst>(this) ||
1422-
isa<OpenExistentialBoxValueInst>(this)) {
1421+
isa<OpenExistentialValueInst>(this) ||
1422+
isa<OpenExistentialBoxInst>(this) ||
1423+
isa<OpenExistentialBoxValueInst>(this) ||
1424+
isa<OpenPackElementInst>(this)) {
14231425
// Don't know how to duplicate these properly yet. Inst.clone() per
14241426
// instruction does not work. Because the follow-up instructions need to
14251427
// reuse the same archetype uuid which would only work if we used a

lib/SILOptimizer/Utils/LoopUtils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,9 @@ bool swift::canDuplicateLoopInstruction(SILLoop *L, SILInstruction *I) {
280280

281281
// We can't have a phi of two openexistential instructions of different UUID.
282282
if (isa<OpenExistentialAddrInst>(I) || isa<OpenExistentialRefInst>(I) ||
283-
isa<OpenExistentialMetatypeInst>(I) ||
284-
isa<OpenExistentialValueInst>(I) || isa<OpenExistentialBoxInst>(I) ||
285-
isa<OpenExistentialBoxValueInst>(I)) {
283+
isa<OpenExistentialMetatypeInst>(I) || isa<OpenExistentialValueInst>(I) ||
284+
isa<OpenExistentialBoxInst>(I) || isa<OpenExistentialBoxValueInst>(I) ||
285+
isa<OpenPackElementInst>(I)) {
286286
SingleValueInstruction *OI = cast<SingleValueInstruction>(I);
287287
for (auto *UI : OI->getUses())
288288
if (!L->contains(UI->getUser()))

0 commit comments

Comments
 (0)