Skip to content

[MachineVerifier] Fix LiveInterval verification of unwinding instructions #131565

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions llvm/lib/CodeGen/MachineVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3837,15 +3837,6 @@ void MachineVerifier::verifyLiveRangeSegment(const LiveRange &LR,
// Check that VNI is live-out of all predecessors.
for (const MachineBasicBlock *Pred : MFI->predecessors()) {
SlotIndex PEnd = LiveInts->getMBBEndIdx(Pred);
// Predecessor of landing pad live-out on last call.
if (MFI->isEHPad()) {
for (const MachineInstr &MI : llvm::reverse(*Pred)) {
if (MI.isCall()) {
PEnd = Indexes->getInstructionIndex(MI).getBoundaryIndex();
break;
}
}
}
const VNInfo *PVNI = LR.getVNInfoBefore(PEnd);

// All predecessors must have a live-out value. However for a phi
Expand Down
48 changes: 48 additions & 0 deletions llvm/test/CodeGen/WebAssembly/cleanupret-live-intervals.mir
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# RUN: llc -mattr=+exception-handling -wasm-enable-eh -exception-model=wasm -verify-machineinstrs -run-pass=liveintervals %s

# This is a regression test for a bug where MachineVerifier compute live-outs of
# a BB not from the end of a BB but the last call instruction, which is not
# correct when there is another unwinding instruction after the call.

--- |
target triple = "wasm32-unknown-unknown"

declare void @foo()
declare void @bar(i32)
define void @cleanupret_live_range_test() {
ret void
}
...
---
name: cleanupret_live_range_test
liveins:
- { reg: '$arguments' }
tracksRegLiveness: true
body: |
bb.0:
successors: %bb.1, %bb.2
EH_LABEL <mcsymbol .Ltmp2>
CALL @foo, implicit-def dead $arguments, implicit $sp32, implicit $sp64
EH_LABEL <mcsymbol .Ltmp3>
BR %bb.1, implicit-def dead $arguments

bb.1:
; predecessors: %bb.0
UNREACHABLE implicit-def dead $arguments

bb.2 (landing-pad):
; predecessors: %bb.0
successors: %bb.3
EH_LABEL <mcsymbol .Ltmp4>
CALL @foo, implicit-def dead $arguments, implicit $sp32, implicit $sp64
; Because bb.3's use of %0's def is here, the live-outs from the predecessor
; bb.2 should be from the terminator (CLEANUPRET) and not the 'CALL @foo'
; above.
%0:i32 = CONST_I32 0, implicit-def dead $arguments
CLEANUPRET %bb.2, implicit-def dead $arguments

bb.3 (landing-pad):
; predecessors: %bb.2
EH_LABEL <mcsymbol .Ltmp5>
CALL @bar, %0:i32, implicit-def dead $arguments, implicit $sp32, implicit $sp64
CLEANUPRET %bb.3, implicit-def dead $arguments
66 changes: 0 additions & 66 deletions llvm/test/CodeGen/X86/windows-seh-EHa-RegisterLiveness.ll

This file was deleted.