|
34 | 34 | #include "swift/IRGen/Linking.h" |
35 | 35 | #include "swift/SIL/ApplySite.h" |
36 | 36 | #include "swift/SIL/BasicBlockDatastructures.h" |
| 37 | +#include "swift/SIL/BasicBlockUtils.h" |
37 | 38 | #include "swift/SIL/Dominance.h" |
38 | 39 | #include "swift/SIL/InstructionUtils.h" |
39 | 40 | #include "swift/SIL/MemAccessUtils.h" |
|
44 | 45 | #include "swift/SIL/SILLinkage.h" |
45 | 46 | #include "swift/SIL/SILModule.h" |
46 | 47 | #include "swift/SIL/SILType.h" |
| 48 | +#include "swift/SIL/SILValue.h" |
47 | 49 | #include "swift/SIL/SILVisitor.h" |
48 | 50 | #include "swift/SIL/TerminatorUtils.h" |
49 | 51 | #include "clang/AST/ASTContext.h" |
@@ -411,6 +413,9 @@ class IRGenSILFunction : |
411 | 413 | /// metadata is emitted has some corresponding cleanup instructions. |
412 | 414 | llvm::DenseMap<SILInstruction *, llvm::SmallVector<SILInstruction *, 2>> |
413 | 415 | DynamicMetadataPackDeallocs; |
| 416 | + |
| 417 | + // A cached dead-end blocks analysis. |
| 418 | + std::unique_ptr<DeadEndBlocks> DeadEnds; |
414 | 419 | #endif |
415 | 420 | /// For each instruction which did allocate pack metadata on-stack, the stack |
416 | 421 | /// locations at which they were allocated. |
@@ -685,6 +690,15 @@ class IRGenSILFunction : |
685 | 690 | return Name; |
686 | 691 | } |
687 | 692 |
|
| 693 | +#ifndef NDEBUG |
| 694 | + DeadEndBlocks *getDeadEndBlocks() { |
| 695 | + if (!DeadEnds) { |
| 696 | + DeadEnds.reset(new DeadEndBlocks(CurSILFn)); |
| 697 | + } |
| 698 | + return DeadEnds.get(); |
| 699 | + } |
| 700 | +#endif |
| 701 | + |
688 | 702 | /// To make it unambiguous whether a `var` binding has been initialized, |
689 | 703 | /// zero-initialize the shadow copy alloca. LLDB uses the first pointer-sized |
690 | 704 | /// field to recognize to detect uninitialized variables. This can be |
@@ -2744,8 +2758,9 @@ void IRGenSILFunction::visitSILBasicBlock(SILBasicBlock *BB) { |
2744 | 2758 | #ifndef NDEBUG |
2745 | 2759 | if (!OutstandingStackPackAllocs.empty()) { |
2746 | 2760 | auto iter = DynamicMetadataPackDeallocs.find(&I); |
2747 | | - if (iter == DynamicMetadataPackDeallocs.end() || |
2748 | | - iter->getSecond().size() == 0) { |
| 2761 | + if ((iter == DynamicMetadataPackDeallocs.end() || |
| 2762 | + iter->getSecond().size() == 0) && |
| 2763 | + !getDeadEndBlocks()->isDeadEnd(I.getParent())) { |
2749 | 2764 | llvm::errs() |
2750 | 2765 | << "Instruction missing on-stack pack metadata cleanups!\n"; |
2751 | 2766 | I.print(llvm::errs()); |
|
0 commit comments