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

[LiveRange] Verify Other LiveRange in Join API #66809

Merged
merged 1 commit into from
Sep 20, 2023

Conversation

annamthomas
Copy link
Contributor

@annamthomas annamthomas commented Sep 19, 2023

The LiveRange::join API takes in two live ranges. We should verify the
LiveRange passed in to the Join API as well.

@annamthomas annamthomas requested review from 0x59616e and MatzeB and removed request for 0x59616e September 19, 2023 20:05
@llvmbot
Copy link
Member

llvmbot commented Sep 19, 2023

@llvm/pr-subscribers-llvm-regalloc

Changes

The LiveRange::join API takes in two live ranges. We should verify the
LiveRange argument passed in as well.


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

1 Files Affected:

  • (modified) llvm/lib/CodeGen/LiveInterval.cpp (+1)
diff --git a/llvm/lib/CodeGen/LiveInterval.cpp b/llvm/lib/CodeGen/LiveInterval.cpp
index 1cf354349c5610c..a8e45d46c07cee6 100644
--- a/llvm/lib/CodeGen/LiveInterval.cpp
+++ b/llvm/lib/CodeGen/LiveInterval.cpp
@@ -629,6 +629,7 @@ void LiveRange::join(LiveRange &Other,
                      const int *RHSValNoAssignments,
                      SmallVectorImpl<VNInfo *> &NewVNInfo) {
   verify();
+  Other.verify();
 
   // Determine if any of our values are mapped.  This is uncommon, so we want
   // to avoid the range scan if not.

@annamthomas
Copy link
Contributor Author

Just for context, this came up because we saw a crash in LiveRange::join() which cannot be reproduced and we do not have debugInfo on the core.

When cross-referencing the asm of the function to the source code, we see the crash is in this code, with S.valno being null:

// Rewrite Other values before changing the VNInfo ids.
  // This can leave Other in an invalid state because we're not coalescing
  // touching segments that now have identical values. That's OK since Other is
  // not supposed to be valid after calling join();
  for (Segment &S : Other.segments)
    S.valno = NewVNInfo[RHSValNoAssignments[S.valno->id]];

With Verify() run onOther LiveRange, this will be caught.

@annamthomas annamthomas requested a review from arsenm September 19, 2023 20:26
@annamthomas annamthomas self-assigned this Sep 20, 2023
Copy link
Contributor

@andykaylor andykaylor left a comment

Choose a reason for hiding this comment

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

Looks reasonable

The LiveRange::join API takes in two live ranges. We should verify the
LiveRange argument passed in as well.
@annamthomas annamthomas merged commit 9cfc7ff into llvm:main Sep 20, 2023
@annamthomas annamthomas deleted the LiveRangeVerify branch September 21, 2023 13:25
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