File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
lib/SILOptimizer/Transforms Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -892,11 +892,20 @@ bool DeadObjectElimination::processKeyPath(KeyPathInst *KPI) {
892
892
return false ;
893
893
}
894
894
895
- // For simplicity just bail if the keypath has a non-trivial operands.
896
- // TODO: don't bail but insert compensating destroys for such operands.
897
- for (const Operand &Op : KPI->getPatternOperands ()) {
898
- if (!Op.get ()->getType ().isTrivial (*KPI->getFunction ()))
899
- return false ;
895
+ // In non-ossa, bail out if we have non-trivial pattern operands
896
+ if (!KPI->getFunction ()->hasOwnership ()) {
897
+ for (const Operand &Op : KPI->getPatternOperands ()) {
898
+ if (!Op.get ()->getType ().isTrivial (*KPI->getFunction ()))
899
+ return false ;
900
+ }
901
+ }
902
+
903
+ if (KPI->getFunction ()->hasOwnership ()) {
904
+ for (const Operand &Op : KPI->getPatternOperands ()) {
905
+ if (Op.get ()->getType ().isTrivial (*KPI->getFunction ()))
906
+ continue ;
907
+ SILBuilderWithScope (KPI).createDestroyValue (KPI->getLoc (), Op.get ());
908
+ }
900
909
}
901
910
902
911
// Remove the keypath and all of its users.
You can’t perform that action at this time.
0 commit comments