Index: llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp =================================================================== --- llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp +++ llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp @@ -1876,7 +1876,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]. @@ -1896,6 +1897,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( @@ -1920,6 +1923,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( @@ -1987,8 +1992,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);