Skip to content
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

[CodeLayout] Fixing initialization of empty ranges #68917

Merged
merged 1 commit into from
Oct 13, 2023

Conversation

spupyrev
Copy link
Contributor

@spupyrev spupyrev commented Oct 12, 2023

Fixing libc++'s consistency checks, by eliminating ranges of singular iterators.

@spupyrev spupyrev requested a review from kosarev October 12, 2023 18:16
@spupyrev spupyrev marked this pull request as ready for review October 12, 2023 18:16
@spupyrev
Copy link
Contributor Author

I still cannot repro the issue, so would be great to double check.

@llvmbot
Copy link
Collaborator

llvmbot commented Oct 12, 2023

@llvm/pr-subscribers-llvm-transforms

Author: None (spupyrev)

Changes

Fixing libc++'s consistency checks, by eliminating ranges of singular iterators.


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

1 Files Affected:

  • (modified) llvm/lib/Transforms/Utils/CodeLayout.cpp (+6-3)
diff --git a/llvm/lib/Transforms/Utils/CodeLayout.cpp b/llvm/lib/Transforms/Utils/CodeLayout.cpp
index 057a5e86c04aca1..6a789e5187f1310 100644
--- a/llvm/lib/Transforms/Utils/CodeLayout.cpp
+++ b/llvm/lib/Transforms/Utils/CodeLayout.cpp
@@ -476,13 +476,16 @@ void ChainT::mergeEdges(ChainT *Other) {
 }
 
 using NodeIter = std::vector<NodeT *>::const_iterator;
+static std::vector<NodeT *> EmptyList;
 
 /// A wrapper around three chains of nodes; it is used to avoid extra
 /// instantiation of the vectors.
 struct MergedChain {
-  MergedChain(NodeIter Begin1, NodeIter End1, NodeIter Begin2 = NodeIter(),
-              NodeIter End2 = NodeIter(), NodeIter Begin3 = NodeIter(),
-              NodeIter End3 = NodeIter())
+  MergedChain(NodeIter Begin1, NodeIter End1,
+              NodeIter Begin2 = EmptyList.begin(),
+              NodeIter End2 = EmptyList.end(),
+              NodeIter Begin3 = EmptyList.begin(),
+              NodeIter End3 = EmptyList.end())
       : Begin1(Begin1), End1(End1), Begin2(Begin2), End2(End2), Begin3(Begin3),
         End3(End3) {}
 

Copy link
Collaborator

@kosarev kosarev left a comment

Choose a reason for hiding this comment

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

This fixes it. Thanks!

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