Skip to content

Commit e56dbb4

Browse files
committed
Improve SILCombine mark_dependence: handle address dependence.
1 parent 74b235e commit e56dbb4

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/SILOptimizer/SILCombiner/SILCombinerMiscVisitors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1961,7 +1961,7 @@ SILInstruction *SILCombiner::visitMarkDependenceInst(MarkDependenceInst *mdi) {
19611961
// does not have a meaning, so just eliminate it.
19621962
{
19631963
SILType baseType = mdi->getBase()->getType();
1964-
if (baseType.isObject() && baseType.isTrivial(*mdi->getFunction())) {
1964+
if (baseType.getObjectType().isTrivial(*mdi->getFunction())) {
19651965
SILValue value = mdi->getValue();
19661966
mdi->replaceAllUsesWith(value);
19671967
return eraseInstFromFunction(*mdi);

test/SILOptimizer/sil_combine.sil

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3785,6 +3785,22 @@ bb0(%0 : $B):
37853785
return %2 : $B
37863786
}
37873787

3788+
// CHECK-LABEL: sil @mark_dependence_trivial_address_base :
3789+
// CHECK: bb0(
3790+
// CHECK-NEXT: strong_retain
3791+
// CHECK-NEXT: alloc_stack $Int
3792+
// CHECK-NEXT: dealloc_stack
3793+
// CHECK-NEXT: return
3794+
// CHECK: } // end sil function 'mark_dependence_trivial_address_base'
3795+
sil @mark_dependence_trivial_address_base : $@convention(thin) (@guaranteed B) -> @owned B {
3796+
bb0(%0 : $B):
3797+
strong_retain %0 : $B
3798+
%1 = alloc_stack $Int
3799+
%2 = mark_dependence %0 : $B on %1 : $*Int
3800+
dealloc_stack %1 : $*Int
3801+
return %2 : $B
3802+
}
3803+
37883804
protocol _NSArrayCore {}
37893805

37903806
// CHECK-LABEL: sil @mark_dependence_base2

0 commit comments

Comments
 (0)