aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/UnreachableBlockElim.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/CodeGen/UnreachableBlockElim.cpp b/lib/CodeGen/UnreachableBlockElim.cpp
index 19341ee721..ca682fd65a 100644
--- a/lib/CodeGen/UnreachableBlockElim.cpp
+++ b/lib/CodeGen/UnreachableBlockElim.cpp
@@ -27,6 +27,7 @@
#include "llvm/Pass.h"
#include "llvm/Type.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
+#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Target/TargetInstrInfo.h"
@@ -128,10 +129,15 @@ bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) {
start->RemoveOperand(i-1);
}
- if (start->getNumOperands() == 1) {
+ if (start->getNumOperands() == 3) {
MachineInstr* phi = start;
+ unsigned Input = phi->getOperand(1).getReg();
+ unsigned Output = phi->getOperand(0).getReg();
+
start++;
phi->eraseFromParent();
+
+ F.getRegInfo().replaceRegWith(Output, Input);
} else
start++;
}