[PATCH] D144732: [Assignment Tracking] Elide a map copy in some cases

Jeremy Morse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 23 03:00:09 PDT 2023


jmorse accepted this revision.
jmorse added a comment.
This revision is now accepted and ready to land.

LGTM with a question; this does introduce knarlyness, so we should revisit this if we manage to make the pass faster.



================
Comment at: llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp:1778-1779
+  if (VisitedPreds.empty()) {
+    bool DidInsert = LiveIn.try_emplace(&BB, BlockInfo()).second;
+    return /*Changed*/ DidInsert;
+  }
----------------
To confirm my understanding: with no predecessors visited, there's no information in BlockInfo, and this attempts to place it in the live-in maps. If this block has already been visited then there can _only_ be an empty BlockInfo there already, so it's safe to use "try_emplace" and allow it to fail. Failure means the same BlockInfo is in the map, but we don't need to explore any further because there's been no change.

(I worry that try_emplace failing would cause exploration to cease too early, but if the above is true, then it's sound).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144732/new/

https://reviews.llvm.org/D144732



More information about the llvm-commits mailing list