Skip to content

Commit df6e2eb

Browse files
authored
[NFC] Fix use-after-free issues in debug printing inside SIL Mem2Reg (#42183)
Turned printing of addresses of instructions into instructions while there.
1 parent d2fad71 commit df6e2eb

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/SILOptimizer/Transforms/SILMem2Reg.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ StoreInst *StackAllocationPromoter::promoteAllocationInBlock(
651651
"store [assign] to the stack location should have been "
652652
"transformed to a store [init]");
653653
LLVM_DEBUG(llvm::dbgs()
654-
<< "*** Removing redundant store: " << lastStoreInst->value);
654+
<< "*** Removing redundant store: " << *lastStoreInst->value);
655655
++NumInstRemoved;
656656
prepareForDeletion(lastStoreInst->value, instructionsToDelete);
657657
}
@@ -746,7 +746,7 @@ StoreInst *StackAllocationPromoter::promoteAllocationInBlock(
746746
"store [assign] to the stack location should have been "
747747
"transformed to a store [init]");
748748
LLVM_DEBUG(llvm::dbgs() << "*** Finished promotion. Last store: "
749-
<< lastStoreInst->value);
749+
<< *lastStoreInst->value);
750750
return lastStoreInst->value;
751751
}
752752

@@ -887,11 +887,11 @@ void StackAllocationPromoter::fixPhiPredBlock(BlockSetVector &phiBlocks,
887887
SILBasicBlock *destBlock,
888888
SILBasicBlock *predBlock) {
889889
TermInst *ti = predBlock->getTerminator();
890-
LLVM_DEBUG(llvm::dbgs() << "*** Fixing the terminator " << ti << ".\n");
890+
LLVM_DEBUG(llvm::dbgs() << "*** Fixing the terminator " << *ti << ".\n");
891891

892892
LiveValues def = getEffectiveLiveOutValues(phiBlocks, predBlock);
893893

894-
LLVM_DEBUG(llvm::dbgs() << "*** Found the definition: " << *def.copy);
894+
LLVM_DEBUG(llvm::dbgs() << "*** Found the definition: " << def.replacement(asi));
895895

896896
llvm::SmallVector<SILValue> vals;
897897
vals.push_back(def.stored);
@@ -1748,9 +1748,8 @@ bool MemoryToRegisters::promoteSingleAllocation(AllocStackInst *alloc) {
17481748

17491749
// Remove write-only AllocStacks.
17501750
if (isWriteOnlyAllocation(alloc) && !shouldAddLexicalLifetime(alloc)) {
1751-
deleter.forceDeleteWithUsers(alloc);
1752-
17531751
LLVM_DEBUG(llvm::dbgs() << "*** Deleting store-only AllocStack: "<< *alloc);
1752+
deleter.forceDeleteWithUsers(alloc);
17541753
return true;
17551754
}
17561755

0 commit comments

Comments
 (0)