diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-12-13 14:20:37 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-12-13 14:20:37 -0800 |
commit | 318376f61cc49474bdf0e05077d654629d98440e (patch) | |
tree | 6e39e43a81a080cc6144234778046ce18a661b2c /lib/Target/CppBackend/CPPBackend.cpp | |
parent | 5e088a0259ccde4f5ffa511d1a1d8d1913dd6c16 (diff) |
fix relooper usage where we created duplicate branches in switches
Diffstat (limited to 'lib/Target/CppBackend/CPPBackend.cpp')
-rw-r--r-- | lib/Target/CppBackend/CPPBackend.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index bc58c97d70..f1744df7cd 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -2197,7 +2197,8 @@ void CppWriter::printFunctionBody(const Function *F) { BasicBlock *DD = SI->getDefaultDest(); std::string P = getPhiCode(&*BI, DD); LLVMToRelooper[&*BI]->AddBranchTo(LLVMToRelooper[&*DD], NULL, P.size() > 0 ? P.c_str() : NULL); - std::map<const BasicBlock*, std::string> BlocksToConditions; + typedef std::map<const BasicBlock*, std::string> BlockCondMap; + BlockCondMap BlocksToConditions; for (SwitchInst::ConstCaseIt i = SI->case_begin(), e = SI->case_end(); i != e; ++i) { const BasicBlock *BB = i.getCaseSuccessor(); const IntegersSubset CaseVal = i.getCaseValueEx(); @@ -2214,10 +2215,10 @@ void CppWriter::printFunctionBody(const Function *F) { } BlocksToConditions[BB] = Condition + (!UseSwitch && BlocksToConditions[BB].size() > 0 ? " | " : "") + BlocksToConditions[BB]; } - for (SwitchInst::ConstCaseIt i = SI->case_begin(), e = SI->case_end(); i != e; ++i) { - const BasicBlock *BB = i.getCaseSuccessor(); + for (BlockCondMap::iterator I = BlocksToConditions.begin(), E = BlocksToConditions.end(); I != E; ++I) { + const BasicBlock *BB = I->first; std::string P = getPhiCode(&*BI, BB); - LLVMToRelooper[&*BI]->AddBranchTo(LLVMToRelooper[&*BB], BlocksToConditions[BB].c_str(), P.size() > 0 ? P.c_str() : NULL); + LLVMToRelooper[&*BI]->AddBranchTo(LLVMToRelooper[&*BB], I->second.c_str(), P.size() > 0 ? P.c_str() : NULL); } break; } |