aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/CppBackend/CPPBackend.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-11-24 11:46:46 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-11-24 11:46:46 -0800
commit4bd6fc1f1df91829bad53502a1bb0453a6d43b61 (patch)
tree878a22b4f44774e1a4d5222dbfdb3af6b68f1583 /lib/Target/CppBackend/CPPBackend.cpp
parente543aa1e828580538cdbdf04331799ad3c0efb5f (diff)
handle unreachable
Diffstat (limited to 'lib/Target/CppBackend/CPPBackend.cpp')
-rw-r--r--lib/Target/CppBackend/CPPBackend.cpp49
1 files changed, 24 insertions, 25 deletions
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp
index 9482796b76..a0ac3cf4aa 100644
--- a/lib/Target/CppBackend/CPPBackend.cpp
+++ b/lib/Target/CppBackend/CPPBackend.cpp
@@ -1342,9 +1342,7 @@ std::string CppWriter::generateInstruction(const Instruction *I) {
break;
}
case Instruction::Unreachable: {
- Out << "new UnreachableInst("
- << "mod->getContext(), "
- << bbname << ");";
+ text += "abort();";
break;
}
case Instruction::Add:
@@ -2052,29 +2050,30 @@ void CppWriter::printFunctionBody(const Function *F) {
BI != BE; ++BI) {
const TerminatorInst *TI = BI->getTerminator();
switch (TI->getOpcode()) {
- default: {
- dumpfailv("invalid branch instr %s\n", TI->getOpcodeName());
- break;
- }
- case Instruction::Br: {
- const BranchInst* br = cast<BranchInst>(TI);
- if (br->getNumOperands() == 3) {
- BasicBlock *S0 = br->getSuccessor(0);
- BasicBlock *S1 = br->getSuccessor(1);
- std::string P0 = getPhiCode(&*BI, S0);
- std::string P1 = getPhiCode(&*BI, S1);
- LLVMToRelooper[&*BI]->AddBranchTo(LLVMToRelooper[&*S0], getOpName(TI->getOperand(0)).c_str(), P0.size() > 0 ? P0.c_str() : NULL);
- LLVMToRelooper[&*BI]->AddBranchTo(LLVMToRelooper[&*S1], NULL, P1.size() > 0 ? P1.c_str() : NULL);
- } else if (br->getNumOperands() == 1) {
- BasicBlock *S = br->getSuccessor(0);
- std::string P = getPhiCode(&*BI, S);
- LLVMToRelooper[&*BI]->AddBranchTo(LLVMToRelooper[&*S], NULL, P.size() > 0 ? P.c_str() : NULL);
- } else {
- error("Branch with 2 operands?");
+ default: {
+ dumpfailv("invalid branch instr %s\n", TI->getOpcodeName());
+ break;
}
- break;
- }
- case Instruction::Ret: break;
+ case Instruction::Br: {
+ const BranchInst* br = cast<BranchInst>(TI);
+ if (br->getNumOperands() == 3) {
+ BasicBlock *S0 = br->getSuccessor(0);
+ BasicBlock *S1 = br->getSuccessor(1);
+ std::string P0 = getPhiCode(&*BI, S0);
+ std::string P1 = getPhiCode(&*BI, S1);
+ LLVMToRelooper[&*BI]->AddBranchTo(LLVMToRelooper[&*S0], getOpName(TI->getOperand(0)).c_str(), P0.size() > 0 ? P0.c_str() : NULL);
+ LLVMToRelooper[&*BI]->AddBranchTo(LLVMToRelooper[&*S1], NULL, P1.size() > 0 ? P1.c_str() : NULL);
+ } else if (br->getNumOperands() == 1) {
+ BasicBlock *S = br->getSuccessor(0);
+ std::string P = getPhiCode(&*BI, S);
+ LLVMToRelooper[&*BI]->AddBranchTo(LLVMToRelooper[&*S], NULL, P.size() > 0 ? P.c_str() : NULL);
+ } else {
+ error("Branch with 2 operands?");
+ }
+ break;
+ }
+ case Instruction::Ret:
+ case Instruction::Unreachable: break;
}
}