File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
lib/SILOptimizer/Transforms Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -565,6 +565,7 @@ void SSADestroyHoisting::run() {
565
565
566
566
llvm::SmallVector<AllocStackInst *, 4 > asis;
567
567
llvm::SmallVector<BeginAccessInst *, 4 > bais;
568
+ llvm::SmallVector<StoreInst *, 4 > sis;
568
569
569
570
// Collect the instructions that we'll be transforming.
570
571
for (auto &block : *getFunction ()) {
@@ -575,10 +576,32 @@ void SSADestroyHoisting::run() {
575
576
if (bai->getAccessKind () == SILAccessKind::Modify) {
576
577
bais.push_back (bai);
577
578
}
579
+ } else if (auto *si = dyn_cast<StoreInst>(&inst)) {
580
+ if (si->getOwnershipQualifier () == StoreOwnershipQualifier::Assign) {
581
+ sis.push_back (si);
582
+ }
578
583
}
579
584
}
580
585
}
581
586
587
+ // Before hoisting, expand all
588
+ //
589
+ // store [assign]
590
+ //
591
+ // instructions into
592
+ //
593
+ // destroy_addr
594
+ // store [init]
595
+ //
596
+ // sequences to create more destroy_addrs to hoist.
597
+ for (auto *si : sis) {
598
+ auto builder = SILBuilderWithScope (si);
599
+ builder.createDestroyAddr (
600
+ RegularLocation::getAutoGeneratedLocation (si->getLoc ()),
601
+ si->getOperand (1 ));
602
+ si->setOwnershipQualifier (StoreOwnershipQualifier::Init);
603
+ }
604
+
582
605
// We assume that the function is in reverse post order so visiting the
583
606
// blocks and pushing begin_access as we see them and then popping them off
584
607
// the end will result in hoisting inner begin_access' destroy_addrs first.
You can’t perform that action at this time.
0 commit comments