|
16 | 16 | //===----------------------------------------------------------------------===// |
17 | 17 |
|
18 | 18 | #include "GenKeyPath.h" |
19 | | -#include "swift/AST/ExtInfo.h" |
20 | 19 | #include "swift/AST/ASTContext.h" |
21 | 20 | #include "swift/AST/ASTMangler.h" |
22 | 21 | #include "swift/AST/DiagnosticsIRGen.h" |
| 22 | +#include "swift/AST/ExtInfo.h" |
23 | 23 | #include "swift/AST/GenericEnvironment.h" |
24 | 24 | #include "swift/AST/IRGenOptions.h" |
25 | 25 | #include "swift/AST/ParameterList.h" |
|
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" |
@@ -410,6 +412,9 @@ class IRGenSILFunction : |
410 | 412 | /// metadata is emitted has some corresponding cleanup instructions. |
411 | 413 | llvm::DenseMap<SILInstruction *, llvm::SmallVector<SILInstruction *, 2>> |
412 | 414 | DynamicMetadataPackDeallocs; |
| 415 | + |
| 416 | + // A cached dead-end blocks analysis. |
| 417 | + std::unique_ptr<DeadEndBlocks> DeadEnds; |
413 | 418 | #endif |
414 | 419 | /// For each instruction which did allocate pack metadata on-stack, the stack |
415 | 420 | /// locations at which they were allocated. |
@@ -680,6 +685,15 @@ class IRGenSILFunction : |
680 | 685 | return Name; |
681 | 686 | } |
682 | 687 |
|
| 688 | +#ifndef NDEBUG |
| 689 | + DeadEndBlocks *getDeadEndBlocks() { |
| 690 | + if (!DeadEnds) { |
| 691 | + DeadEnds.reset(new DeadEndBlocks(CurSILFn)); |
| 692 | + } |
| 693 | + return DeadEnds.get(); |
| 694 | + } |
| 695 | +#endif |
| 696 | + |
683 | 697 | /// To make it unambiguous whether a `var` binding has been initialized, |
684 | 698 | /// zero-initialize the shadow copy alloca. LLDB uses the first pointer-sized |
685 | 699 | /// field to recognize to detect uninitialized variables. This can be |
@@ -2736,8 +2750,9 @@ void IRGenSILFunction::visitSILBasicBlock(SILBasicBlock *BB) { |
2736 | 2750 | #ifndef NDEBUG |
2737 | 2751 | if (!OutstandingStackPackAllocs.empty()) { |
2738 | 2752 | auto iter = DynamicMetadataPackDeallocs.find(&I); |
2739 | | - if (iter == DynamicMetadataPackDeallocs.end() || |
2740 | | - iter->getSecond().size() == 0) { |
| 2753 | + if ((iter == DynamicMetadataPackDeallocs.end() || |
| 2754 | + iter->getSecond().size() == 0) && |
| 2755 | + !getDeadEndBlocks()->isDeadEnd(I.getParent())) { |
2741 | 2756 | llvm::errs() |
2742 | 2757 | << "Instruction missing on-stack pack metadata cleanups!\n"; |
2743 | 2758 | I.print(llvm::errs()); |
|
0 commit comments