mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
An sinkable instruction may exist with uses, if those uses are in dead blocks.
Handle this. This fixes PR908 and Transforms/LICM/2006-09-12-DeadUserOfSunkInstr.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30275 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -447,6 +447,8 @@ void LICM::sink(Instruction &I) {
|
|||||||
if (!isExitBlockDominatedByBlockInLoop(ExitBlocks[0], I.getParent())) {
|
if (!isExitBlockDominatedByBlockInLoop(ExitBlocks[0], I.getParent())) {
|
||||||
// Instruction is not used, just delete it.
|
// Instruction is not used, just delete it.
|
||||||
CurAST->deleteValue(&I);
|
CurAST->deleteValue(&I);
|
||||||
|
if (!I.use_empty()) // If I has users in unreachable blocks, eliminate.
|
||||||
|
I.replaceAllUsesWith(UndefValue::get(I.getType()));
|
||||||
I.eraseFromParent();
|
I.eraseFromParent();
|
||||||
} else {
|
} else {
|
||||||
// Move the instruction to the start of the exit block, after any PHI
|
// Move the instruction to the start of the exit block, after any PHI
|
||||||
@ -460,6 +462,8 @@ void LICM::sink(Instruction &I) {
|
|||||||
} else if (ExitBlocks.size() == 0) {
|
} else if (ExitBlocks.size() == 0) {
|
||||||
// The instruction is actually dead if there ARE NO exit blocks.
|
// The instruction is actually dead if there ARE NO exit blocks.
|
||||||
CurAST->deleteValue(&I);
|
CurAST->deleteValue(&I);
|
||||||
|
if (!I.use_empty()) // If I has users in unreachable blocks, eliminate.
|
||||||
|
I.replaceAllUsesWith(UndefValue::get(I.getType()));
|
||||||
I.eraseFromParent();
|
I.eraseFromParent();
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, if we have multiple exits, use the PromoteMem2Reg function to
|
// Otherwise, if we have multiple exits, use the PromoteMem2Reg function to
|
||||||
|
Reference in New Issue
Block a user