Skip to content

Commit 7e11809

Browse files
authored
Merge pull request #29632 from gottesmm/pr-0071f3d29aed40bc5467e019b4191f7ce624e042
2 parents b4771c2 + 377b7b1 commit 7e11809

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

include/swift/SIL/PatternMatch.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,12 @@ template <typename LTy> struct tupleextractoperation_ty {
397397
unsigned index;
398398
tupleextractoperation_ty(const LTy &Left, unsigned i) : L(Left), index(i) {}
399399

400-
bool match(SILValue v) { return match(v->getDefiningInstruction()); }
400+
bool match(SILValue v) {
401+
auto *inst = v->getDefiningInstruction();
402+
if (!inst)
403+
return false;
404+
return match(inst);
405+
}
401406

402407
template <typename ITy> bool match(ITy *V) {
403408
if (auto *TEI = dyn_cast<TupleExtractInst>(V)) {

test/SILOptimizer/sil_combine.sil

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,6 +2422,16 @@ bb0(%0 : $Builtin.Int64, %1 : $Builtin.RawPointer, %2 : $Builtin.RawPointer):
24222422
return %13 : $()
24232423
}
24242424

2425+
// Make sure we do not crash here. This ensures that when checking for
2426+
// tuple_extract, we check if we have an argument or not.
2427+
sil @builtin_array_opt_index_raw_pointer_to_index_addr_no_crash : $@convention(thin) (Builtin.RawPointer, Builtin.Word) -> Builtin.Word {
2428+
bb0(%0 : $Builtin.RawPointer, %1 : $Builtin.Word):
2429+
%2 = index_raw_pointer %0 : $Builtin.RawPointer, %1 : $Builtin.Word
2430+
%3 = pointer_to_address %2 : $Builtin.RawPointer to [strict] $*Builtin.Word
2431+
%4 = load %3 : $*Builtin.Word
2432+
return %4 : $Builtin.Word
2433+
}
2434+
24252435
// CHECK-LABEL: sil @cmp_zext_peephole
24262436
// CHECK: bb0([[Arg1:%.*]] : $Builtin.Word, [[Arg2:%.*]] : $Builtin.Word):
24272437
// CHECK: [[ZA1:%.*]] = builtin "zextOrBitCast_Word_Int64"([[Arg1]] : $Builtin.Word) : $Builtin.Int64

0 commit comments

Comments
 (0)