Skip to content

Conversation

@NaiveWang
Copy link

In DebugTypeInfoRemoval, DenseMap Replacements's assignment's rvalue is a recursive function that may access Replacements itself. Since C++17 such an "right to left" order cannot get guaranteed. This change is to separate 1 line into 2, avoid such a case.

In DebugTypeInfoRemoval, DenseMap Replacements's assignment's rvalue is a recursive function that may access Replacements itself. Since C++17 such an "right to left" order cannot get guaranteed.
This change is to separate 1 line into 2.
@github-actions
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot
Copy link
Member

llvmbot commented Jan 25, 2025

@llvm/pr-subscribers-debuginfo

@llvm/pr-subscribers-llvm-ir

Author: Elvin Wang (NaiveWang)

Changes

In DebugTypeInfoRemoval, DenseMap Replacements's assignment's rvalue is a recursive function that may access Replacements itself. Since C++17 such an "right to left" order cannot get guaranteed. This change is to separate 1 line into 2, avoid such a case.


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

1 Files Affected:

  • (modified) llvm/lib/IR/DebugInfo.cpp (+2-1)
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 4ce518009bd3ea..f4080ce532ef38 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -798,7 +798,8 @@ class DebugTypeInfoRemoval {
 
       return getReplacementMDNode(N);
     };
-    Replacements[N] = doRemap(N);
+    auto value = doRemap(N);
+    Replacements[N] = value;
   }
 
   /// Do the remapping traversal.

@NaiveWang NaiveWang changed the title Fix potential Out-of-order Evaluation in DebugInfo [llvm] Fix potential Out-of-order Evaluation in DebugInfo Jan 25, 2025
@dwblaikie
Copy link
Collaborator

Perhaps add a comment so someone doesn't undo this too easily in the future?

Copy link
Collaborator

@dwblaikie dwblaikie left a comment

Choose a reason for hiding this comment

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

In the comment, maybe clarify that doRemap can recurse back into remap (& so modify Replacements, etc)

@NaiveWang
Copy link
Author

@dwblaikie I will draft another formal upstream patch using corp account when everything's ready, thanks for the review, closing this one.

@NaiveWang NaiveWang closed this Jan 29, 2025
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.

3 participants