@@ -1103,27 +1103,25 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
11031103 FrameTy->getElementType (FrameData.getFieldIndex (E.first )), GEP,
11041104 SpillAlignment, E.first ->getName () + Twine (" .reload" ));
11051105
1106- TinyPtrVector<DbgDeclareInst *> DIs = findDbgDeclares (Def);
11071106 TinyPtrVector<DbgVariableRecord *> DVRs = findDVRDeclares (Def);
11081107 // Try best to find dbg.declare. If the spill is a temp, there may not
11091108 // be a direct dbg.declare. Walk up the load chain to find one from an
11101109 // alias.
11111110 if (F->getSubprogram ()) {
11121111 auto *CurDef = Def;
1113- while (DIs. empty () && DVRs.empty () && isa<LoadInst>(CurDef)) {
1112+ while (DVRs.empty () && isa<LoadInst>(CurDef)) {
11141113 auto *LdInst = cast<LoadInst>(CurDef);
11151114 // Only consider ptr to ptr same type load.
11161115 if (LdInst->getPointerOperandType () != LdInst->getType ())
11171116 break ;
11181117 CurDef = LdInst->getPointerOperand ();
11191118 if (!isa<AllocaInst, LoadInst>(CurDef))
11201119 break ;
1121- DIs = findDbgDeclares (CurDef);
11221120 DVRs = findDVRDeclares (CurDef);
11231121 }
11241122 }
11251123
1126- auto SalvageOne = [&](auto *DDI) {
1124+ auto SalvageOne = [&](DbgVariableRecord *DDI) {
11271125 // This dbg.declare is preserved for all coro-split function
11281126 // fragments. It will be unreachable in the main function, and
11291127 // processed by coro::salvageDebugInfo() by the Cloner.
@@ -1137,7 +1135,6 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
11371135 // will be deleted in all coro-split functions.
11381136 coro::salvageDebugInfo (ArgToAllocaMap, *DDI, false /* UseEntryValue*/ );
11391137 };
1140- for_each (DIs, SalvageOne);
11411138 for_each (DVRs, SalvageOne);
11421139 }
11431140
@@ -1225,8 +1222,7 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
12251222 SmallVector<DbgVariableIntrinsic *, 4 > DIs;
12261223 SmallVector<DbgVariableRecord *> DbgVariableRecords;
12271224 findDbgUsers (DIs, Alloca, &DbgVariableRecords);
1228- for (auto *DVI : DIs)
1229- DVI->replaceUsesOfWith (Alloca, G);
1225+ assert (DIs.empty () && " Should never see debug-intrinsics" );
12301226 for (auto *DVR : DbgVariableRecords)
12311227 DVR->replaceVariableLocationOp (Alloca, G);
12321228
@@ -1920,48 +1916,6 @@ salvageDebugInfoImpl(SmallDenseMap<Argument *, AllocaInst *, 4> &ArgToAllocaMap,
19201916 return {{*Storage, *Expr}};
19211917}
19221918
1923- void coro::salvageDebugInfo (
1924- SmallDenseMap<Argument *, AllocaInst *, 4 > &ArgToAllocaMap,
1925- DbgVariableIntrinsic &DVI, bool UseEntryValue) {
1926-
1927- Function *F = DVI.getFunction ();
1928- // Follow the pointer arithmetic all the way to the incoming
1929- // function argument and convert into a DIExpression.
1930- bool SkipOutermostLoad = !isa<DbgValueInst>(DVI);
1931- Value *OriginalStorage = DVI.getVariableLocationOp (0 );
1932-
1933- auto SalvagedInfo =
1934- ::salvageDebugInfoImpl (ArgToAllocaMap, UseEntryValue, F, OriginalStorage,
1935- DVI.getExpression(), SkipOutermostLoad);
1936- if (!SalvagedInfo)
1937- return ;
1938-
1939- Value *Storage = &SalvagedInfo->first ;
1940- DIExpression *Expr = &SalvagedInfo->second ;
1941-
1942- DVI.replaceVariableLocationOp (OriginalStorage, Storage);
1943- DVI.setExpression (Expr);
1944- // We only hoist dbg.declare today since it doesn't make sense to hoist
1945- // dbg.value since it does not have the same function wide guarantees that
1946- // dbg.declare does.
1947- if (isa<DbgDeclareInst>(DVI)) {
1948- std::optional<BasicBlock::iterator> InsertPt;
1949- if (auto *I = dyn_cast<Instruction>(Storage)) {
1950- InsertPt = I->getInsertionPointAfterDef ();
1951- // Update DILocation only if variable was not inlined.
1952- DebugLoc ILoc = I->getDebugLoc ();
1953- DebugLoc DVILoc = DVI.getDebugLoc ();
1954- if (ILoc && DVILoc &&
1955- DVILoc->getScope ()->getSubprogram () ==
1956- ILoc->getScope ()->getSubprogram ())
1957- DVI.setDebugLoc (I->getDebugLoc ());
1958- } else if (isa<Argument>(Storage))
1959- InsertPt = F->getEntryBlock ().begin ();
1960- if (InsertPt)
1961- DVI.moveBefore (*(*InsertPt)->getParent (), *InsertPt);
1962- }
1963- }
1964-
19651919void coro::salvageDebugInfo (
19661920 SmallDenseMap<Argument *, AllocaInst *, 4 > &ArgToAllocaMap,
19671921 DbgVariableRecord &DVR, bool UseEntryValue) {
0 commit comments