Skip to content

Commit bddc50e

Browse files
committed
LargeTypesReg2Mem: Handle mark_dependence
This instruction is a no-op. We can just delete it. rdar://129873110
1 parent 8c5d9e2 commit bddc50e

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lib/IRGen/LoadableByAddress.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3631,6 +3631,14 @@ class AssignAddressToDef : SILInstructionVisitor<AssignAddressToDef> {
36313631
singleValueInstructionFallback(kp);
36323632
}
36333633

3634+
void visitMarkDependenceInst(MarkDependenceInst *mark) {
3635+
// This instruction is purely for semantic tracking in SIL.
3636+
// Simply forward the value and delete the instruction.
3637+
auto valAddr = assignment.getAddressForValue(mark->getValue());
3638+
assignment.mapValueToAddress(mark, valAddr);
3639+
assignment.markForDeletion(mark);
3640+
}
3641+
36343642
void visitBeginApplyInst(BeginApplyInst *apply) {
36353643
auto builder = assignment.getBuilder(++apply->getIterator());
36363644
auto addr = assignment.createAllocStack(origValue->getType());

test/IRGen/loadable_by_address_reg2mem.sil

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,21 @@ bb0(%0 : $*union_t):
296296
dealloc_stack %1 : $*union_t
297297
return %13 : $()
298298
}
299+
300+
// This test case used to crash because we did not handle `mark_dependence`.
301+
sil @test12 : $@convention(thin) () -> () {
302+
bb0:
303+
%0 = alloc_stack $X
304+
%1 = alloc_stack $Y
305+
%2 = alloc_stack $X
306+
%3 = load %0 : $*X
307+
%4 = load %2 : $*X
308+
%5 = mark_dependence %3 : $X on %4 : $X
309+
%6 = struct $Y (%5 : $X , %5 : $X)
310+
store %6 to %1 : $*Y
311+
dealloc_stack %2 : $*X
312+
dealloc_stack %1 : $*Y
313+
dealloc_stack %0 : $*X
314+
%t = tuple ()
315+
return %t : $()
316+
}

0 commit comments

Comments
 (0)