diff options
author | Tanya Lattner <tonic@nondot.org> | 2010-03-23 17:15:19 +0000 |
---|---|---|
committer | Tanya Lattner <tonic@nondot.org> | 2010-03-23 17:15:19 +0000 |
commit | 650437f2ef17f6a36682545ff2f14236ef732c29 (patch) | |
tree | f78a4b2f687419aaf63e0dd05ae3c2272c51a279 | |
parent | 3e7b991362a600aed2ea0b24d6602bbbe797723c (diff) | |
download | llvm-650437f2ef17f6a36682545ff2f14236ef732c29.zip llvm-650437f2ef17f6a36682545ff2f14236ef732c29.tar.gz llvm-650437f2ef17f6a36682545ff2f14236ef732c29.tar.bz2 |
Merge 98977 from mainline.
llvm-svn: 99292
-rw-r--r-- | llvm/include/llvm/CodeGen/MachineJumpTableInfo.h | 4 | ||||
-rw-r--r-- | llvm/lib/CodeGen/BranchFolding.cpp | 34 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MachineFunction.cpp | 11 |
3 files changed, 6 insertions, 43 deletions
diff --git a/llvm/include/llvm/CodeGen/MachineJumpTableInfo.h b/llvm/include/llvm/CodeGen/MachineJumpTableInfo.h index c578d28..b92ed7b 100644 --- a/llvm/include/llvm/CodeGen/MachineJumpTableInfo.h +++ b/llvm/include/llvm/CodeGen/MachineJumpTableInfo.h @@ -83,10 +83,6 @@ public: /// unsigned createJumpTableIndex(const std::vector<MachineBasicBlock*> &DestBBs); - /// getJumpTableIndex - Return the index for an existing jump table. - /// - unsigned getJumpTableIndex(const std::vector<MachineBasicBlock*> &DestBBs); - /// isEmpty - Return true if there are no jump tables. /// bool isEmpty() const { return JumpTables.empty(); } diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp index d94729a..d41a134 100644 --- a/llvm/lib/CodeGen/BranchFolding.cpp +++ b/llvm/lib/CodeGen/BranchFolding.cpp @@ -203,7 +203,7 @@ bool BranchFolder::OptimizeFunction(MachineFunction &MF, MadeChange |= MadeChangeThisIteration; } - // See if any jump tables have become mergable or dead as the code generator + // See if any jump tables have become dead as the code generator // did its thing. MachineJumpTableInfo *JTI = MF.getJumpTableInfo(); if (JTI == 0) { @@ -211,27 +211,8 @@ bool BranchFolder::OptimizeFunction(MachineFunction &MF, return MadeChange; } - const std::vector<MachineJumpTableEntry> &JTs = JTI->getJumpTables(); - // Figure out how these jump tables should be merged. - std::vector<unsigned> JTMapping; - JTMapping.reserve(JTs.size()); - - // We always keep the 0th jump table. - JTMapping.push_back(0); - - // Scan the jump tables, seeing if there are any duplicates. Note that this - // is N^2, which should be fixed someday. - for (unsigned i = 1, e = JTs.size(); i != e; ++i) { - if (JTs[i].MBBs.empty()) - JTMapping.push_back(i); - else - JTMapping.push_back(JTI->getJumpTableIndex(JTs[i].MBBs)); - } - - // If a jump table was merge with another one, walk the function rewriting - // references to jump tables to reference the new JT ID's. Keep track of - // whether we see a jump table idx, if not, we can delete the JT. - BitVector JTIsLive(JTs.size()); + // Walk the function to find jump tables that are live. + BitVector JTIsLive(JTI->getJumpTables().size()); for (MachineFunction::iterator BB = MF.begin(), E = MF.end(); BB != E; ++BB) { for (MachineBasicBlock::iterator I = BB->begin(), E = BB->end(); @@ -239,17 +220,14 @@ bool BranchFolder::OptimizeFunction(MachineFunction &MF, for (unsigned op = 0, e = I->getNumOperands(); op != e; ++op) { MachineOperand &Op = I->getOperand(op); if (!Op.isJTI()) continue; - unsigned NewIdx = JTMapping[Op.getIndex()]; - Op.setIndex(NewIdx); // Remember that this JT is live. - JTIsLive.set(NewIdx); + JTIsLive.set(Op.getIndex()); } } - // Finally, remove dead jump tables. This happens either because the - // indirect jump was unreachable (and thus deleted) or because the jump - // table was merged with some other one. + // Finally, remove dead jump tables. This happens when the + // indirect jump was unreachable (and thus deleted). for (unsigned i = 0, e = JTIsLive.size(); i != e; ++i) if (!JTIsLive.test(i)) { JTI->RemoveJumpTable(i); diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index ccbb2dd..33d8400 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -603,17 +603,6 @@ unsigned MachineJumpTableInfo::createJumpTableIndex( return JumpTables.size()-1; } -/// getJumpTableIndex - Return the index for an existing jump table entry in -/// the jump table info. -unsigned MachineJumpTableInfo::getJumpTableIndex( - const std::vector<MachineBasicBlock*> &DestBBs) { - for (unsigned i = 0, e = JumpTables.size(); i != e; ++i) - if (JumpTables[i].MBBs == DestBBs) - return i; - assert(false && "getJumpTableIndex failed to find matching table"); - return ~0; -} - /// ReplaceMBBInJumpTables - If Old is the target of any jump tables, update /// the jump tables to branch to New instead. bool MachineJumpTableInfo::ReplaceMBBInJumpTables(MachineBasicBlock *Old, |