Index: llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp =================================================================== --- llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp +++ llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp @@ -1840,7 +1840,8 @@ /// These tasks are bundled together to reduce the number of times we need /// to iterate over the function as they can be achieved together in one pass. static AssignmentTrackingLowering::OverlapMap buildOverlapMapAndRecordDeclares( - Function &Fn, FunctionVarLocsBuilder *FnVarLocs, + Function &Fn, const DenseSet &VarsWithStackSlot, + FunctionVarLocsBuilder *FnVarLocs, AssignmentTrackingLowering::UntaggedStoreAssignmentMap &UntaggedStoreVars) { DenseSet Seen; // Map of Variable: [Fragments]. @@ -1860,6 +1861,8 @@ } else if (auto *DII = dyn_cast(&I)) { DebugVariable DV = DebugVariable(DII); DebugAggregate DA = {DV.getVariable(), DV.getInlinedAt()}; + if (!VarsWithStackSlot.contains(DA)) + continue; if (Seen.insert(DV).second) FragmentMap[DA].push_back(DV); } else if (auto Info = getUntaggedStoreAssignmentInfo( @@ -1884,6 +1887,8 @@ DebugVariable DV = DebugVariable(DAI->getVariable(), FragInfo, DAI->getDebugLoc().getInlinedAt()); DebugAggregate DA = {DV.getVariable(), DV.getInlinedAt()}; + if (!VarsWithStackSlot.contains(DA)) + continue; // Cache this info for later. UntaggedStoreVars[&I].push_back( @@ -1951,8 +1956,8 @@ // Note that this pass doesn't handle partial overlaps correctly (FWIW // neither does LiveDebugVariables) because that is difficult to do and // appears to be rare occurance. - VarContains = - buildOverlapMapAndRecordDeclares(Fn, FnVarLocs, UntaggedStoreVars); + VarContains = buildOverlapMapAndRecordDeclares(Fn, *VarsWithStackSlot, + FnVarLocs, UntaggedStoreVars); // Prepare for traversal. ReversePostOrderTraversal RPOT(&Fn);