aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineFunction.cpp
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2010-03-18 18:42:41 +0000
committerBob Wilson <bob.wilson@apple.com>2010-03-18 18:42:41 +0000
commit3c7cde466e5047f32586573fa6d47388aeffc563 (patch)
tree1137387419bb6f2eb38b25173dd57725f524696b /llvm/lib/CodeGen/MachineFunction.cpp
parent48d09cab6677689ea50b591b70cab11624b0f250 (diff)
downloadllvm-3c7cde466e5047f32586573fa6d47388aeffc563.zip
llvm-3c7cde466e5047f32586573fa6d47388aeffc563.tar.gz
llvm-3c7cde466e5047f32586573fa6d47388aeffc563.tar.bz2
Fix pr6543: svn r88806 changed MachineJumpTableInfo::getJumpTableIndex() to
always create a new jump table. The intention was to avoid merging jump tables in SelectionDAGBuilder, and to wait for the branch folding pass to merge tables. Unfortunately, the same getJumpTableIndex() method is also used to merge tables in branch folding, so as a result of this change branch tables are never merged. Worse, the branch folding code is expecting getJumpTableIndex to always return the index of an existing table, but with this change, it never does so. In at least some cases, e.g., pr6543, this creates references to non-existent tables. I've fixed the problem by adding a new createJumpTableIndex function, which will always create a new table, and I've changed getJumpTableIndex to only look at existing tables. llvm-svn: 98845
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunction.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineFunction.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index 37f3d22..254b5e7c 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -600,16 +600,25 @@ unsigned MachineJumpTableInfo::getEntryAlignment(const TargetData &TD) const {
return ~0;
}
-/// getJumpTableIndex - Create a new jump table entry in the jump table info
-/// or return an existing one.
+/// createJumpTableIndex - Create a new jump table entry in the jump table info.
///
-unsigned MachineJumpTableInfo::getJumpTableIndex(
+unsigned MachineJumpTableInfo::createJumpTableIndex(
const std::vector<MachineBasicBlock*> &DestBBs) {
assert(!DestBBs.empty() && "Cannot create an empty jump table!");
JumpTables.push_back(MachineJumpTableEntry(DestBBs));
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.