[PATCH] D34902: [RegisterCoalescer] Account for instructions deleted by removePartialredunduncy and in WorkList
Sameer AbuAsal via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 30 12:19:33 PDT 2017
sabuasal created this revision.
Herald added subscribers: qcolombet, MatzeB.
removePartialRedundency optimization introduces a state in the
RegisterCoalescer where an instruction pointed to in the WorkList
is deleted from the MBB and then removed from the ErasedList. Update
ErasedList to be used globally by not erasing erased Instructions from
it to solve the problem. The patch also accounts for the case where an Instruction was previously
deleted and the same memory was reused by BuildMI to create a new instruction.
I discovered these problem in an out of tree build.
Repository:
rL LLVM
https://reviews.llvm.org/D34902
Files:
lib/CodeGen/RegisterCoalescer.cpp
Index: lib/CodeGen/RegisterCoalescer.cpp
===================================================================
--- lib/CodeGen/RegisterCoalescer.cpp
+++ lib/CodeGen/RegisterCoalescer.cpp
@@ -979,6 +979,11 @@
IntB.createDeadDef(NewCopyIdx, LIS->getVNInfoAllocator());
for (LiveInterval::SubRange &SR : IntB.subranges())
SR.createDeadDef(NewCopyIdx, LIS->getVNInfoAllocator());
+
+ // If the newly created Instruction has an address of an instruction that was
+ // deleted before (object recycled by the allocator) it needs to be removed from
+ // the deleted list.
+ ErasedInstrs.erase(NewCopyMI);
} else {
DEBUG(dbgs() << "\tremovePartialRedundancy: Remove the copy from BB#"
<< MBB.getNumber() << '\t' << CopyMI);
@@ -989,6 +994,8 @@
// While updating the live-ranges, we only look at slot indices and
// never go back to the instruction.
LIS->RemoveMachineInstrFromMaps(CopyMI);
+ // Mark instructions as deleted.
+ ErasedInstrs.insert(&CopyMI);
CopyMI.eraseFromParent();
// Update the liveness.
@@ -3095,7 +3102,7 @@
continue;
// Skip instruction pointers that have already been erased, for example by
// dead code elimination.
- if (ErasedInstrs.erase(CurrList[i])) {
+ if (ErasedInstrs.count(CurrList[i])) {
CurrList[i] = nullptr;
continue;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34902.104908.patch
Type: text/x-patch
Size: 1362 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170630/4c3bc619/attachment.bin>
More information about the llvm-commits
mailing list