[llvm] 8638fe1 - [X86] Fix livein handling in emitStackProbeInlineWindowsCoreCLR64. (#106828)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 31 10:12:03 PDT 2024
Author: Craig Topper
Date: 2024-08-31T10:11:59-07:00
New Revision: 8638fe1444a532c660f1ef2b93816cf6af6b05e9
URL: https://github.com/llvm/llvm-project/commit/8638fe1444a532c660f1ef2b93816cf6af6b05e9
DIFF: https://github.com/llvm/llvm-project/commit/8638fe1444a532c660f1ef2b93816cf6af6b05e9.diff
LOG: [X86] Fix livein handling in emitStackProbeInlineWindowsCoreCLR64. (#106828)
Stop adding liveins for virtual registers. In the livein interface, the
register goes through a MCPhysReg which is uint16_t. This causes the
virtual register bit to be dropped making it alias to some nonsense
physical register.
Recompute the liveins for the continue block to handle any live
registers that are needed by instructions that were spliced from the
original block. This fixing the machine verifier error so we can remove
that fixme now.
Added:
Modified:
llvm/lib/Target/X86/X86FrameLowering.cpp
llvm/test/CodeGen/X86/win_coreclr_chkstk.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86FrameLowering.cpp b/llvm/lib/Target/X86/X86FrameLowering.cpp
index 43a3219f789c4a..e7c725ded4bdef 100644
--- a/llvm/lib/Target/X86/X86FrameLowering.cpp
+++ b/llvm/lib/Target/X86/X86FrameLowering.cpp
@@ -1037,7 +1037,8 @@ void X86FrameLowering::emitStackProbeInlineWindowsCoreCLR64(
.addImm(X86::COND_AE);
// Add code to roundMBB to round the final stack pointer to a page boundary.
- RoundMBB->addLiveIn(FinalReg);
+ if (InProlog)
+ RoundMBB->addLiveIn(FinalReg);
BuildMI(RoundMBB, DL, TII.get(X86::AND64ri32), RoundedReg)
.addReg(FinalReg)
.addImm(PageMask);
@@ -1054,7 +1055,8 @@ void X86FrameLowering::emitStackProbeInlineWindowsCoreCLR64(
.addMBB(LoopMBB);
}
- LoopMBB->addLiveIn(JoinReg);
+ if (InProlog)
+ LoopMBB->addLiveIn(JoinReg);
addRegOffset(BuildMI(LoopMBB, DL, TII.get(X86::LEA64r), ProbeReg), JoinReg,
false, -PageSize);
@@ -1067,7 +1069,8 @@ void X86FrameLowering::emitStackProbeInlineWindowsCoreCLR64(
.addReg(0)
.addImm(0);
- LoopMBB->addLiveIn(RoundedReg);
+ if (InProlog)
+ LoopMBB->addLiveIn(RoundedReg);
BuildMI(LoopMBB, DL, TII.get(X86::CMP64rr))
.addReg(RoundedReg)
.addReg(ProbeReg);
@@ -1091,7 +1094,6 @@ void X86FrameLowering::emitStackProbeInlineWindowsCoreCLR64(
// Now that the probing is done, add code to continueMBB to update
// the stack pointer for real.
- ContinueMBB->addLiveIn(SizeReg);
BuildMI(*ContinueMBB, ContinueMBBI, DL, TII.get(X86::SUB64rr), X86::RSP)
.addReg(X86::RSP)
.addReg(SizeReg);
@@ -1103,6 +1105,11 @@ void X86FrameLowering::emitStackProbeInlineWindowsCoreCLR64(
LoopMBB->addSuccessor(ContinueMBB);
LoopMBB->addSuccessor(LoopMBB);
+ if (InProlog) {
+ LivePhysRegs LiveRegs;
+ computeAndAddLiveIns(LiveRegs, *ContinueMBB);
+ }
+
// Mark all the instructions added to the prolog as frame setup.
if (InProlog) {
for (++BeforeMBBI; BeforeMBBI != MBB.end(); ++BeforeMBBI) {
diff --git a/llvm/test/CodeGen/X86/win_coreclr_chkstk.ll b/llvm/test/CodeGen/X86/win_coreclr_chkstk.ll
index c169521ca3803c..35fc13be0f86bd 100644
--- a/llvm/test/CodeGen/X86/win_coreclr_chkstk.ll
+++ b/llvm/test/CodeGen/X86/win_coreclr_chkstk.ll
@@ -1,5 +1,4 @@
-; FIXME: Fix machine verifier issues and remove -verify-machineinstrs=0. PR38376.
-; RUN: llc < %s -mtriple=x86_64-pc-win32-coreclr -verify-machineinstrs=0 | FileCheck %s -check-prefix=WIN_X64
+; RUN: llc < %s -mtriple=x86_64-pc-win32-coreclr -verify-machineinstrs | FileCheck %s -check-prefix=WIN_X64
; RUN: llc < %s -mtriple=x86_64-pc-linux | FileCheck %s -check-prefix=LINUX
; By default, windows CoreCLR requires an inline prologue stack expansion check
More information about the llvm-commits
mailing list