[PATCH] D145515: [Assignment Tracking][NFC] Only calculate fragment overlaps for partially stack homed variables

Orlando Cazalet-Hyams via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 7 08:46:27 PST 2023


Orlando created this revision.
Orlando added reviewers: scott.linder, StephenTozer, jmorse.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Orlando requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This filter is already applied to the rest of the analysis - this change simply prevents some unnecessary work.


https://reviews.llvm.org/D145515

Files:
  llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp


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<DebugAggregate> *VarsWithStackSlot,
+    FunctionVarLocsBuilder *FnVarLocs,
     AssignmentTrackingLowering::UntaggedStoreAssignmentMap &UntaggedStoreVars) {
   DenseSet<DebugVariable> Seen;
   // Map of Variable: [Fragments].
@@ -1896,6 +1897,8 @@
       } else if (auto *DII = dyn_cast<DbgVariableIntrinsic>(&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<Function *> RPOT(&Fn);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145515.503068.patch
Type: text/x-patch
Size: 2157 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230307/d1e7d10c/attachment.bin>


More information about the llvm-commits mailing list