-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
RegAllocFast::runOnMachineFunction
misses a virtual register
#59172
Comments
In case the reduction lost anything meaningful, here's the full original input: rustc_demangle-legacy.bc.gz |
I found that I tried inserting --- a/llvm/lib/CodeGen/RegAllocFast.cpp
+++ b/llvm/lib/CodeGen/RegAllocFast.cpp
@@ -453,8 +453,8 @@ void RegAllocFast::spill(MachineBasicBlock::iterator Before, Register VirtReg,
MachineInstr *NewDV = buildDbgValueForSpill(
*MBB, Before, *MISpilledOperands.first, FI, MISpilledOperands.second);
assert(NewDV->getParent() == MBB && "dangling parent pointer");
- (void)NewDV;
LLVM_DEBUG(dbgs() << "Inserting debug info due to spill:\n" << *NewDV);
+ handleDebugValue(*NewDV);
if (LiveOut) {
// We need to insert a DBG_VALUE at the end of the block if the spill slot
@@ -464,6 +464,7 @@ void RegAllocFast::spill(MachineBasicBlock::iterator Before, Register VirtReg,
MachineInstr *ClonedDV = MBB->getParent()->CloneMachineInstr(NewDV);
MBB->insert(FirstTerm, ClonedDV);
LLVM_DEBUG(dbgs() << "Cloning debug info due to live out spill\n");
+ handleDebugValue(*ClonedDV);
}
// Rewrite unassigned dbg_values to use the stack slot. I'm not sure if that's generally correct though... |
Submitted https://reviews.llvm.org/D139590 |
@llvm/issue-subscribers-debuginfo |
These new debug values get inserted after the place where the spill happens, which means they won't be reached by the reverse traversal of basic block instructions. This would crash or fail assertions if they contained any virtual registers to be replaced. We can manually handle the new debug values right away to resolve this. Fixes llvm/llvm-project#59172 Reviewed By: StephenTozer Differential Revision: https://reviews.llvm.org/D139590
/cherry-pick 87f57f4 |
/branch llvm/llvm-project-release-prs/issue59172 |
These new debug values get inserted after the place where the spill happens, which means they won't be reached by the reverse traversal of basic block instructions. This would crash or fail assertions if they contained any virtual registers to be replaced. We can manually handle the new debug values right away to resolve this. Fixes llvm/llvm-project#59172 Reviewed By: StephenTozer Differential Revision: https://reviews.llvm.org/D139590 (cherry picked from commit 87f57f4)
/pull-request llvm/llvm-project-release-prs#226 |
Is this a regression? |
No -- or not recent anyway. |
@cuviper When I run the test file through |
These new debug values get inserted after the place where the spill happens, which means they won't be reached by the reverse traversal of basic block instructions. This would crash or fail assertions if they contained any virtual registers to be replaced. We can manually handle the new debug values right away to resolve this. Fixes llvm#59172 Reviewed By: StephenTozer Differential Revision: https://reviews.llvm.org/D139590 (cherry picked from commit 87f57f4)
/branch nikic/llvm-project/fast-ra-dbg-backport Account for a small change in instruction scheduling in the test. |
/branch nikic/llvm-project/fast-ra-dbg-backport |
/pull-request llvm/llvm-project-release-prs#228 |
@nikic The following bc comes from Rust + LLVM-14. This doesn't crash a normal build of rustc_demangle-legacy-reduced-function.bc.gz I'm assuming the crash itself is not very interesting when it comes from earlier bad state, and not crashing may just mean that the bad memory access landed somewhere harmless. (Not that I want to argue against a backport though!) |
These new debug values get inserted after the place where the spill happens, which means they won't be reached by the reverse traversal of basic block instructions. This would crash or fail assertions if they contained any virtual registers to be replaced. We can manually handle the new debug values right away to resolve this. Fixes llvm/llvm-project#59172 Reviewed By: StephenTozer Differential Revision: https://reviews.llvm.org/D139590 (cherry picked from commit 87f57f4)
Given this input: reduced.ll.txt
In a build without assertions,
llc -O0
crashes:With assertions, this fails earlier in
MachineRegisterInfo::clearVirtRegs
:The input file is a reduction from a Rust build with LTO -- optimized+debuginfo code from the standard library merged with unoptimized code from the test case. After reduction, only one
std
function remains. It compiles fine withllc -O1
or higher, or withllc -O0 --optimize-regalloc
.xref: https://bugzilla.redhat.com/show_bug.cgi?id=2142648
The text was updated successfully, but these errors were encountered: