@@ -613,11 +613,10 @@ bool llvm::replaceDbgUsesWithUndef(Instruction *I) {
613613 SmallVector<DbgVariableIntrinsic *, 1 > DbgUsers;
614614 SmallVector<DbgVariableRecord *, 1 > DPUsers;
615615 findDbgUsers (DbgUsers, I, &DPUsers);
616- for (auto *DII : DbgUsers)
617- DII->setKillLocation ();
616+ assert (DbgUsers.empty ());
618617 for (auto *DVR : DPUsers)
619618 DVR->setKillLocation ();
620- return !DbgUsers. empty () || ! DPUsers.empty ();
619+ return !DPUsers.empty ();
621620}
622621
623622// / areAllUsesEqual - Check whether the uses of a value are all the same.
@@ -2022,6 +2021,7 @@ void llvm::salvageDebugInfo(Instruction &I) {
20222021 SmallVector<DbgVariableIntrinsic *, 1 > DbgUsers;
20232022 SmallVector<DbgVariableRecord *, 1 > DPUsers;
20242023 findDbgUsers (DbgUsers, &I, &DPUsers);
2024+ assert (DbgUsers.empty ());
20252025 salvageDebugInfoForDbgValues (I, DbgUsers, DPUsers);
20262026}
20272027
@@ -2070,66 +2070,9 @@ void llvm::salvageDebugInfoForDbgValues(
20702070 const unsigned MaxExpressionSize = 128 ;
20712071 bool Salvaged = false ;
20722072
2073- for (auto *DII : DbgUsers) {
2074- if (auto *DAI = dyn_cast<DbgAssignIntrinsic>(DII)) {
2075- if (DAI->getAddress () == &I) {
2076- salvageDbgAssignAddress (DAI);
2077- Salvaged = true ;
2078- }
2079- if (DAI->getValue () != &I)
2080- continue ;
2081- }
2082-
2083- // Do not add DW_OP_stack_value for DbgDeclare, because they are implicitly
2084- // pointing out the value as a DWARF memory location description.
2085- bool StackValue = isa<DbgValueInst>(DII);
2086- auto DIILocation = DII->location_ops ();
2087- assert (
2088- is_contained (DIILocation, &I) &&
2089- " DbgVariableIntrinsic must use salvaged instruction as its location" );
2090- SmallVector<Value *, 4 > AdditionalValues;
2091- // `I` may appear more than once in DII's location ops, and each use of `I`
2092- // must be updated in the DIExpression and potentially have additional
2093- // values added; thus we call salvageDebugInfoImpl for each `I` instance in
2094- // DIILocation.
2095- Value *Op0 = nullptr ;
2096- DIExpression *SalvagedExpr = DII->getExpression ();
2097- auto LocItr = find (DIILocation, &I);
2098- while (SalvagedExpr && LocItr != DIILocation.end ()) {
2099- SmallVector<uint64_t , 16 > Ops;
2100- unsigned LocNo = std::distance (DIILocation.begin (), LocItr);
2101- uint64_t CurrentLocOps = SalvagedExpr->getNumLocationOperands ();
2102- Op0 = salvageDebugInfoImpl (I, CurrentLocOps, Ops, AdditionalValues);
2103- if (!Op0)
2104- break ;
2105- SalvagedExpr =
2106- DIExpression::appendOpsToArg (SalvagedExpr, Ops, LocNo, StackValue);
2107- LocItr = std::find (++LocItr, DIILocation.end (), &I);
2108- }
2109- // salvageDebugInfoImpl should fail on examining the first element of
2110- // DbgUsers, or none of them.
2111- if (!Op0)
2112- break ;
2073+ // We should never see debug intrinsics nowadays.
2074+ assert (DbgUsers.empty ());
21132075
2114- SalvagedExpr = SalvagedExpr->foldConstantMath ();
2115- DII->replaceVariableLocationOp (&I, Op0);
2116- bool IsValidSalvageExpr = SalvagedExpr->getNumElements () <= MaxExpressionSize;
2117- if (AdditionalValues.empty () && IsValidSalvageExpr) {
2118- DII->setExpression (SalvagedExpr);
2119- } else if (isa<DbgValueInst>(DII) && IsValidSalvageExpr &&
2120- DII->getNumVariableLocationOps () + AdditionalValues.size () <=
2121- MaxDebugArgs) {
2122- DII->addVariableLocationOps (AdditionalValues, SalvagedExpr);
2123- } else {
2124- // Do not salvage using DIArgList for dbg.declare, as it is not currently
2125- // supported in those instructions. Also do not salvage if the resulting
2126- // DIArgList would contain an unreasonably large number of values.
2127- DII->setKillLocation ();
2128- }
2129- LLVM_DEBUG (dbgs () << " SALVAGE: " << *DII << ' \n ' );
2130- Salvaged = true ;
2131- }
2132- // Duplicate of above block for DbgVariableRecords.
21332076 for (auto *DVR : DPUsers) {
21342077 if (DVR->isDbgAssign ()) {
21352078 if (DVR->getAddress () == &I) {
@@ -2198,9 +2141,6 @@ void llvm::salvageDebugInfoForDbgValues(
21982141 if (Salvaged)
21992142 return ;
22002143
2201- for (auto *DII : DbgUsers)
2202- DII->setKillLocation ();
2203-
22042144 for (auto *DVR : DPUsers)
22052145 DVR->setKillLocation ();
22062146}
@@ -3429,8 +3369,7 @@ void llvm::dropDebugUsers(Instruction &I) {
34293369 SmallVector<DbgVariableIntrinsic *, 1 > DbgUsers;
34303370 SmallVector<DbgVariableRecord *, 1 > DPUsers;
34313371 findDbgUsers (DbgUsers, &I, &DPUsers);
3432- for (auto *DII : DbgUsers)
3433- DII->eraseFromParent ();
3372+ assert (DbgUsers.empty ());
34343373 for (auto *DVR : DPUsers)
34353374 DVR->eraseFromParent ();
34363375}
0 commit comments