Skip to content

Refine the examples in the debug info document #86272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 9, 2024

Conversation

Apochens
Copy link
Contributor

This PR modifies the examples of section "When to merge instruction locations" in HowToUpdateDebugInfo according to the discussion, removing one misleading counterexample and refining the description of hoisting identical instructions.

@llvmbot
Copy link
Member

llvmbot commented Mar 22, 2024

@llvm/pr-subscribers-debuginfo

Author: Shan Huang (Apochens)

Changes

This PR modifies the examples of section "When to merge instruction locations" in HowToUpdateDebugInfo according to the discussion, removing one misleading counterexample and refining the description of hoisting identical instructions.


Full diff: https://github.com/llvm/llvm-project/pull/86272.diff

1 Files Affected:

  • (modified) llvm/docs/HowToUpdateDebugInfo.rst (+5-7)
diff --git a/llvm/docs/HowToUpdateDebugInfo.rst b/llvm/docs/HowToUpdateDebugInfo.rst
index c64b5d1d0d98b6..1e36c0c45c8490 100644
--- a/llvm/docs/HowToUpdateDebugInfo.rst
+++ b/llvm/docs/HowToUpdateDebugInfo.rst
@@ -91,8 +91,11 @@ misattributed to a block containing one of the instructions-to-be-merged.
 
 Examples of transformations that should follow this rule include:
 
-* Merging identical loads/stores which occur on both sides of a CFG diamond
-  (see the ``MergedLoadStoreMotion`` pass).
+* Hoisting identical instructions from successors of a conditional branch. For
+  example, merging identical loads/stores which occur on both sides of a CFG
+  diamond (see the ``MergedLoadStoreMotion`` pass). If there are more than one
+  group of identical instructions hoisted, apply merging instruction locations
+  for each single merged instruction.
 
 * Merging identical loop-invariant stores (see the LICM utility
   ``llvm::promoteLoopAccessesToScalars``).
@@ -115,11 +118,6 @@ Examples of transformations for which this rule *does not* apply include:
   single-stepping experience. The rule for
   :ref:`dropping locations<WhenToDropLocation>` should apply here.
 
-* Hoisting identical instructions which appear in several successor blocks into
-  a predecessor block (see ``BranchFolder::HoistCommonCodeInSuccs``). In this
-  case there is no single merged instruction. The rule for
-  :ref:`dropping locations<WhenToDropLocation>` applies.
-
 .. _WhenToDropLocation:
 
 When to drop an instruction location

Copy link
Contributor

@SLTozer SLTozer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking at this - changes look broadly good (with some inline comments), but we should give some time for debug info code owners to weigh in, in case they have thoughts.

@@ -91,8 +91,11 @@ misattributed to a block containing one of the instructions-to-be-merged.

Examples of transformations that should follow this rule include:

* Merging identical loads/stores which occur on both sides of a CFG diamond
(see the ``MergedLoadStoreMotion`` pass).
* Hoisting identical instructions from successors of a conditional branch. For
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe Hoisting/sinking? Particularly relevant since the example, MergedLoadStoreMotion, will hoist loads and sink stores.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very crucial reminder!

Comment on lines 96 to 98
diamond (see the ``MergedLoadStoreMotion`` pass). If there are more than one
group of identical instructions hoisted, apply merging instruction locations
for each single merged instruction.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "merging" should be replaced with "merged". Alternatively as an optional suggestion for the last sentence, "For each group of identical instructions being hoisted/sunk, the merge of all their locations should be applied to the merged instruction."

@Apochens Apochens requested review from SLTozer and dwblaikie March 28, 2024 09:25
@Apochens
Copy link
Contributor Author

If there is no other concern, could you please approve this PR so that I could merge it after several days.

@@ -115,11 +119,6 @@ Examples of transformations for which this rule *does not* apply include:
single-stepping experience. The rule for
:ref:`dropping locations<WhenToDropLocation>` should apply here.

* Hoisting identical instructions which appear in several successor blocks into
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there wording we are preserving that covers the case of hoisting/sinking when some but not all successors/predecessors have the instruction? If not, we should probably keep this bullet point and clarify/correct it to refer to this case (of some but not all predecessors/successors)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll handle this.

Copy link
Member

@jmorse jmorse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These revisions SGTM with a wording tweak; I'd suggest leaving this couple of days to allow others to suggest wording changes too. (The overall message seems correct).

* Merging identical loads/stores which occur on both sides of a CFG diamond
(see the ``MergedLoadStoreMotion`` pass).
* Hoisting identical instructions from all successors of a conditional branch
or sinking those from all different predecessors. For example, merging
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel "from all different predecessors" would be better written "from all paths to a postdominating block". The term postdominating should put the reader in mind of the sort of CFG you're describing.

a predecessor block (see ``BranchFolder::HoistCommonCodeInSuccs``). In this
case there is no single merged instruction. The rule for
:ref:`dropping locations<WhenToDropLocation>` applies.
* Hoisting/sinking a part of the identical instructions with the same location.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sentence above reads a bit broken, it's unclear what "a part of the identical instructions" is.
Maybe something like: "Hoisting/sinking that would make a location reachable when it previously wasn't"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is a good suggestion.

@Apochens
Copy link
Contributor Author

Apochens commented Sep 2, 2024

If there are no further suggestions regarding the text changes, I plan to merge this PR at the end of the week.

Thanks for all your efforts!

@Apochens Apochens merged commit ac93554 into llvm:main Sep 9, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants