Skip to content

Commit c98db37

Browse files
authored
Merge pull request swiftlang#8651 from aschwaighofer/swift-4.0-branch-fix-dead-store-elim-value_metatype
Fix DeadStoreElim by not lying about instruction semantics
2 parents ed29977 + 15a12da commit c98db37

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

include/swift/SIL/SILNodes.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ ABSTRACT_VALUE(SILInstruction, ValueBase)
202202

203203
// Metatypes
204204
INST(MetatypeInst, SILInstruction, metatype, None, DoesNotRelease)
205-
INST(ValueMetatypeInst, SILInstruction, value_metatype, None, DoesNotRelease)
205+
INST(ValueMetatypeInst, SILInstruction, value_metatype, MayRead, DoesNotRelease)
206206
INST(ExistentialMetatypeInst, SILInstruction, existential_metatype, MayRead, DoesNotRelease)
207207
INST(ObjCProtocolInst, SILInstruction, objc_protocol, None, DoesNotRelease)
208208

test/SILOptimizer/dead_store_elim.sil

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,3 +1417,19 @@ bb0(%0 : $AB): // Preds: bb6 bb5 bb4 bb3
14171417
dealloc_stack %1 : $*AB
14181418
return %2 : $Builtin.Int1
14191419
}
1420+
1421+
// CHECK-LABEL: dont_remove_store
1422+
// CHECK: load
1423+
// CHECK: store
1424+
// CHECK: value_metatype
1425+
// CHECK: return
1426+
sil @dont_remove_store : $@convention(thin) (@in_guaranteed foo) -> () {
1427+
bb0(%0 : $*foo):
1428+
%1 = alloc_stack $foo
1429+
%2 = load %0 : $*foo
1430+
store %2 to %1 : $*foo
1431+
%3 = value_metatype $@thick foo.Type, %1 : $*foo
1432+
dealloc_stack %1 : $*foo
1433+
%20 = tuple()
1434+
return %20 : $()
1435+
}

0 commit comments

Comments
 (0)