diff options
author | Hans Wennborg <hans@hanshq.net> | 2014-12-01 17:36:43 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2014-12-01 17:36:43 +0000 |
commit | 5bef5b522b55e5631b5c458526cd5eb72106468a (patch) | |
tree | c27f5eb35d799c8b3edfeb6b6b4cb7a9fbd23c85 /llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | |
parent | 269ebb612e656167be56c41da5f5efffa7235125 (diff) | |
download | bcm5719-llvm-5bef5b522b55e5631b5c458526cd5eb72106468a.tar.gz bcm5719-llvm-5bef5b522b55e5631b5c458526cd5eb72106468a.zip |
Revert r223049, r223050 and r223051 while investigating test failures.
I didn't foresee affecting the Clang test suite :/
llvm-svn: 223054
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 59 |
1 files changed, 17 insertions, 42 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index ec6a1367883..fbc1502d500 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -2695,57 +2695,32 @@ void SelectionDAGBuilder::visitSwitch(const SwitchInst &SI) { if (SwitchMBB + 1 != FuncInfo.MF->end()) NextBlock = SwitchMBB + 1; - - // Create a vector of Cases, sorted so that we can efficiently create a binary - // search tree from them. - CaseVector Cases; - Clusterify(Cases, SI); - - // Get the default destination MBB. MachineBasicBlock *Default = FuncInfo.MBBMap[SI.getDefaultDest()]; - if (isa<UnreachableInst>(SI.getDefaultDest()->getFirstNonPHIOrDbg())) { - // Replace an unreachable default destination with the most popular case - // destination. - DenseMap<const BasicBlock*, uint64_t> Popularity; - uint64_t MaxPop = 0; - const BasicBlock *MaxBB = nullptr; - for (auto I : SI.cases()) { - const BasicBlock *BB = I.getCaseSuccessor(); - if (++Popularity[BB] > MaxPop) { - MaxPop = Popularity[BB]; - MaxBB = BB; - } - } - - // Set new default. - Default = FuncInfo.MBBMap[MaxBB]; - - // Remove cases that have been replaced by the default. - CaseItr I = Cases.begin(); - while (I != Cases.end()) { - if (I->BB == Default) { - I = Cases.erase(I); - continue; - } - ++I; - } - } - - // If there is only the default destination, go there directly. - if (Cases.empty()) { + // If there is only the default destination, branch to it if it is not the + // next basic block. Otherwise, just fall through. + if (!SI.getNumCases()) { // Update machine-CFG edges. SwitchMBB->addSuccessor(Default); // If this is not a fall-through branch, emit the branch. - if (Default != NextBlock) { - DAG.setRoot(DAG.getNode(ISD::BR, getCurSDLoc(), MVT::Other, - getControlRoot(), DAG.getBasicBlock(Default))); - } + if (Default != NextBlock) + DAG.setRoot(DAG.getNode(ISD::BR, getCurSDLoc(), + MVT::Other, getControlRoot(), + DAG.getBasicBlock(Default))); + return; } - // Get the Value to be switched on. + // If there are any non-default case statements, create a vector of Cases + // representing each one, and sort the vector so that we can efficiently + // create a binary search tree from them. + CaseVector Cases; + Clusterify(Cases, SI); + + // Get the Value to be switched on and default basic blocks, which will be + // inserted into CaseBlock records, representing basic blocks in the binary + // search tree. const Value *SV = SI.getCondition(); // Push the initial CaseRec onto the worklist |