@@ -1103,27 +1103,25 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
1103
1103
FrameTy->getElementType (FrameData.getFieldIndex (E.first )), GEP,
1104
1104
SpillAlignment, E.first ->getName () + Twine (" .reload" ));
1105
1105
1106
- TinyPtrVector<DbgDeclareInst *> DIs = findDbgDeclares (Def);
1107
1106
TinyPtrVector<DbgVariableRecord *> DVRs = findDVRDeclares (Def);
1108
1107
// Try best to find dbg.declare. If the spill is a temp, there may not
1109
1108
// be a direct dbg.declare. Walk up the load chain to find one from an
1110
1109
// alias.
1111
1110
if (F->getSubprogram ()) {
1112
1111
auto *CurDef = Def;
1113
- while (DIs. empty () && DVRs.empty () && isa<LoadInst>(CurDef)) {
1112
+ while (DVRs.empty () && isa<LoadInst>(CurDef)) {
1114
1113
auto *LdInst = cast<LoadInst>(CurDef);
1115
1114
// Only consider ptr to ptr same type load.
1116
1115
if (LdInst->getPointerOperandType () != LdInst->getType ())
1117
1116
break ;
1118
1117
CurDef = LdInst->getPointerOperand ();
1119
1118
if (!isa<AllocaInst, LoadInst>(CurDef))
1120
1119
break ;
1121
- DIs = findDbgDeclares (CurDef);
1122
1120
DVRs = findDVRDeclares (CurDef);
1123
1121
}
1124
1122
}
1125
1123
1126
- auto SalvageOne = [&](auto *DDI) {
1124
+ auto SalvageOne = [&](DbgVariableRecord *DDI) {
1127
1125
// This dbg.declare is preserved for all coro-split function
1128
1126
// fragments. It will be unreachable in the main function, and
1129
1127
// processed by coro::salvageDebugInfo() by the Cloner.
@@ -1137,7 +1135,6 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
1137
1135
// will be deleted in all coro-split functions.
1138
1136
coro::salvageDebugInfo (ArgToAllocaMap, *DDI, false /* UseEntryValue*/ );
1139
1137
};
1140
- for_each (DIs, SalvageOne);
1141
1138
for_each (DVRs, SalvageOne);
1142
1139
}
1143
1140
@@ -1225,8 +1222,7 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
1225
1222
SmallVector<DbgVariableIntrinsic *, 4 > DIs;
1226
1223
SmallVector<DbgVariableRecord *> DbgVariableRecords;
1227
1224
findDbgUsers (DIs, Alloca, &DbgVariableRecords);
1228
- for (auto *DVI : DIs)
1229
- DVI->replaceUsesOfWith (Alloca, G);
1225
+ assert (DIs.empty () && " Should never see debug-intrinsics" );
1230
1226
for (auto *DVR : DbgVariableRecords)
1231
1227
DVR->replaceVariableLocationOp (Alloca, G);
1232
1228
@@ -1920,48 +1916,6 @@ salvageDebugInfoImpl(SmallDenseMap<Argument *, AllocaInst *, 4> &ArgToAllocaMap,
1920
1916
return {{*Storage, *Expr}};
1921
1917
}
1922
1918
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
-
1965
1919
void coro::salvageDebugInfo (
1966
1920
SmallDenseMap<Argument *, AllocaInst *, 4 > &ArgToAllocaMap,
1967
1921
DbgVariableRecord &DVR, bool UseEntryValue) {
0 commit comments