Skip to content

Commit 75608f0

Browse files
committed
[Outliner] Replace assertion with bail.
Previously, when attempting to pattern-match bridged ObjC properties, there was an assertion about the location of destroy_value instructions in the code that we were trying to match. Instead, bail in the face of an unexpected pattern. rdar://99873905
1 parent ebcb37f commit 75608f0

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lib/SILOptimizer/Transforms/Outliner.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,8 @@ bool BridgedProperty::matchMethodCall(SILBasicBlock::iterator It,
633633
return false;
634634
}
635635
ADVANCE_ITERATOR_OR_RETURN_FALSE(It);
636-
assert(Release == &*It);
636+
if (Release != &*It)
637+
return false;
637638
}
638639

639640
ADVANCE_ITERATOR_OR_RETURN_FALSE(It);

test/SILOptimizer/outliner_ossa.sil

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,3 +281,27 @@ bb3(%64 : @owned $Optional<Data>):
281281
return %102 : $()
282282
}
283283

284+
@objc class Object {
285+
@objc var count: Int { get }
286+
}
287+
class Super {}
288+
289+
class Sub : Super {
290+
var obj: Object
291+
}
292+
293+
// We used to assert here because of an over-strong expectation about the location
294+
// of destroy_value instructions.
295+
sil hidden [ossa] @destroy_after_borrow : $@convention(thin) () -> @owned Sub {
296+
%104 = apply undef() : $@convention(objc_method) () -> @owned Super
297+
%107 = unchecked_ref_cast %104 : $Super to $Sub
298+
%158 = begin_borrow %107 : $Sub
299+
%159 = ref_element_addr %158 : $Sub, #Sub.obj
300+
%160 = load [copy] %159 : $*Object
301+
%161 = objc_method %160 : $Object, #Object.count!getter.foreign : (Object) -> () -> Int, $@convention(objc_method) (Object) -> Int
302+
%162 = apply %161(%160) : $@convention(objc_method) (Object) -> Int
303+
end_borrow %158 : $Sub
304+
destroy_value %160 : $Object
305+
apply undef(%162) : $@convention(thin) (Int) -> ()
306+
return %107 : $Sub
307+
}

0 commit comments

Comments
 (0)