1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

Make SwitchInst::removeCase() more efficient.

llvm-svn: 124659
This commit is contained in:
Jay Foad 2011-02-01 09:22:34 +00:00
parent c03dbe4b1c
commit 89383f48ca
2 changed files with 6 additions and 9 deletions

View File

@ -2247,7 +2247,8 @@ public:
/// removeCase - This method removes the specified successor from the switch
/// instruction. Note that this cannot be used to remove the default
/// destination (successor #0).
/// destination (successor #0). Also note that this operation may reorder the
/// remaining cases at index idx and above.
///
void removeCase(unsigned idx);

View File

@ -3009,14 +3009,10 @@ void SwitchInst::removeCase(unsigned idx) {
unsigned NumOps = getNumOperands();
Use *OL = OperandList;
// Move everything after this operand down.
//
// FIXME: we could just swap with the end of the list, then erase. However,
// client might not expect this to happen. The code as it is thrashes the
// use/def lists, which is kinda lame.
for (unsigned i = (idx+1)*2; i != NumOps; i += 2) {
OL[i-2] = OL[i];
OL[i-2+1] = OL[i+1];
// Overwrite this case with the end of the list.
if ((idx + 1) * 2 != NumOps) {
OL[idx * 2] = OL[NumOps - 2];
OL[idx * 2 + 1] = OL[NumOps - 1];
}
// Nuke the last value.