Skip to content

Commit e3133f7

Browse files
committed
[6.2] LargeTypesReg2Mem: Add unchecked_bitwise_cast to the projections we need to propagate largeness from destination to source operand
Scope: Fixes a compiler crash in some version of swift-collections Issue: An instruction whose result type address'ness needs to be propagated to its operand was not handled. Risk: Low, this case would have crashed without the change. Testing: Unit test added. The compiler successfully compiled the project after this change. Original PR: #80888 rdar://148545382 (cherry picked from commit 370b7e8)
1 parent 393c24d commit e3133f7

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/IRGen/LoadableByAddress.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -3574,6 +3574,7 @@ void LargeLoadableHeuristic::propagate(PostOrderFunctionInfo &po) {
35743574
for (auto *BB : po.getPostOrder()) {
35753575
for (auto &I : llvm::reverse(*BB)) {
35763576
switch (I.getKind()) {
3577+
case SILInstructionKind::UncheckedBitwiseCastInst:
35773578
case SILInstructionKind::TupleExtractInst:
35783579
case SILInstructionKind::StructExtractInst: {
35793580
auto &proj = cast<SingleValueInstruction>(I);

test/IRGen/loadable_by_address_reg2mem.sil

+20
Original file line numberDiff line numberDiff line change
@@ -425,3 +425,23 @@ bb0(%0 : $member_id_t):
425425
%13 = tuple ()
426426
return %13 : $()
427427
}
428+
429+
struct Z {
430+
var r: String
431+
var p: X
432+
}
433+
434+
// CHECK: sil @test17 : $@convention(thin) (@owned String) -> () {
435+
// CHECK: bb0(%0 : $String):
436+
// CHECK: [[T0:%.*]] = alloc_stack $String
437+
// CHECK: store %0 to [[T0]] : $*String
438+
// CHECK: [[T1:%.*]] = unchecked_addr_cast [[T0]] : $*String to $*Z
439+
// CHECK: release_value_addr [[T1]] : $*Z
440+
441+
sil @test17: $@convention(thin) (@owned String) -> () {
442+
bb0(%0 : $String):
443+
%1 = unchecked_bitwise_cast %0 : $String to $Z
444+
release_value %1 : $Z
445+
%13 = tuple ()
446+
return %13 : $()
447+
}

0 commit comments

Comments
 (0)