5050#include " swift/SIL/ApplySite.h"
5151#include " swift/SIL/BasicBlockBits.h"
5252#include " swift/SIL/BasicBlockDatastructures.h"
53+ #include " swift/SIL/DebugUtils.h"
5354#include " swift/SIL/SILBuilder.h"
5455#include " swift/SIL/SILInstruction.h"
5556#include " swift/SIL/SILUndef.h"
@@ -68,22 +69,22 @@ using namespace swift;
6869// Utility
6970// ===----------------------------------------------------------------------===//
7071
71- static SILInstruction *cloneDebugValue (DebugValueInst * original,
72+ static SILInstruction *cloneDebugValue (DebugVarCarryingInst original,
7273 SILInstruction *insertPt) {
7374 SILBuilderWithScope builder (std::next (insertPt->getIterator ()));
7475 builder.setCurrentDebugScope (original->getDebugScope ());
75- return builder.createDebugValue (original-> getLoc (), original-> getOperand (),
76- * original->getVarInfo (), false ,
77- true /* was moved*/ );
76+ return builder.createDebugValue (
77+ original->getLoc (), original. getOperandForDebugValueClone () ,
78+ *original. getVarInfo (), false , true /* was moved*/ );
7879}
7980
80- static SILInstruction *cloneDebugValue (DebugValueInst * original,
81+ static SILInstruction *cloneDebugValue (DebugVarCarryingInst original,
8182 SILBasicBlock *block) {
8283 SILBuilderWithScope builder (&block->front ());
8384 builder.setCurrentDebugScope (original->getDebugScope ());
84- return builder.createDebugValue (original-> getLoc (), original-> getOperand (),
85- * original->getVarInfo (), false ,
86- true /* was moved*/ );
85+ return builder.createDebugValue (
86+ original->getLoc (), original. getOperandForDebugValueClone () ,
87+ *original. getVarInfo (), false , true /* was moved*/ );
8788}
8889
8990// ===----------------------------------------------------------------------===//
@@ -93,7 +94,7 @@ static SILInstruction *cloneDebugValue(DebugValueInst *original,
9394namespace {
9495
9596struct BlockState {
96- llvm::SmallMapVector<SILDebugVariable, DebugValueInst * , 4 > debugValues;
97+ llvm::SmallMapVector<SILDebugVariable, DebugVarCarryingInst , 4 > debugValues;
9798};
9899
99100struct DebugInfoCanonicalizer {
@@ -202,13 +203,20 @@ bool DebugInfoCanonicalizer::process() {
202203 // Then for each inst in the block...
203204 for (auto &inst : *block) {
204205 LLVM_DEBUG (llvm::dbgs () << " Inst: " << inst);
205- // If we have a debug_value that was moved, store state for it.
206- if (auto *dvi = dyn_cast<DebugValueInst>(&inst)) {
207- if (!dvi->getWasMoved ())
206+
207+ // Skip any alloc box inst we see, we do not support them yet.
208+ if (isa<AllocBoxInst>(&inst))
209+ continue ;
210+
211+ // If we have a debug_value or alloc_stack that was moved, store state for
212+ // it. Once the isa check above is removed, this will handle alloc_box as
213+ // well.
214+ if (auto dvi = DebugVarCarryingInst (&inst)) {
215+ if (!dvi.getWasMoved ())
208216 continue ;
209217
210218 LLVM_DEBUG (llvm::dbgs () << " Found DebugValueInst!\n " );
211- auto debugInfo = dvi-> getVarInfo ();
219+ auto debugInfo = dvi. getVarInfo ();
212220 if (!debugInfo) {
213221 LLVM_DEBUG (llvm::dbgs () << " Has no var info?! Skipping!\n " );
214222 continue ;
0 commit comments