This broke the clang testers also btw :) -eric
On Jan 31, 2012, at 11:50 PM, Stepan Dyatkovskiy wrote: > Author: dyatkovskiy > Date: Wed Feb 1 01:50:21 2012 > New Revision: 149482 > > URL: http://llvm.org/viewvc/llvm-project?rev=149482&view=rev > Log: > Compatability fix for SwitchInst refactoring. > > The purpose of refactoring is to hide operand roles from SwitchInst user > (programmer). If you want to play with operands directly, probably you will > need lower level methods than SwitchInst ones (TerminatorInst or may be > User). After this patch we can reorganize SwitchInst operands and successors > as we want. > > What was done: > > 1. Changed semantics of index inside the getCaseValue method: > getCaseValue(0) means "get first case", not a condition. Use getCondition() > if you want to resolve the condition. I propose don't mix SwitchInst case > indexing with low level indexing (TI successors indexing, User's operands > indexing), since it may be dangerous. > 2. By the same reason findCaseValue(ConstantInt*) returns actual number of > case value. 0 means first case, not default. If there is no case with given > value, ErrorIndex will returned. > 3. Added getCaseSuccessor method. I propose to avoid usage of > TerminatorInst::getSuccessor if you want to resolve case successor BB. Use > getCaseSuccessor instead, since internal SwitchInst organization of > operands/successors is hidden and may be changed in any moment. > 4. Added resolveSuccessorIndex and resolveCaseIndex. The main purpose of > these methods is to see how case successors are really mapped in > TerminatorInst. > 4.1 "resolveSuccessorIndex" was created if you need to level down from > SwitchInst to TerminatorInst. It returns TerminatorInst's successor index for > given case successor. > 4.2 "resolveCaseIndex" converts low level successors index to case index that > curresponds to the given successor. > > Note: There are also related compatability fix patches for dragonegg, klee, > llvm-gcc-4.0, llvm-gcc-4.2, safecode, clang. > > Modified: > cfe/trunk/lib/CodeGen/CGCleanup.cpp > cfe/trunk/lib/CodeGen/CGStmt.cpp > > Modified: cfe/trunk/lib/CodeGen/CGCleanup.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.cpp?rev=149482&r1=149481&r2=149482&view=diff > ============================================================================== > --- cfe/trunk/lib/CodeGen/CGCleanup.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGCleanup.cpp Wed Feb 1 01:50:21 2012 > @@ -502,9 +502,9 @@ > > // The only uses should be fixup switches. > llvm::SwitchInst *si = cast<llvm::SwitchInst>(use.getUser()); > - if (si->getNumCases() == 2 && si->getDefaultDest() == unreachableBB) { > + if (si->getNumCases() == 1 && si->getDefaultDest() == unreachableBB) { > // Replace the switch with a branch. > - llvm::BranchInst::Create(si->getSuccessor(1), si); > + llvm::BranchInst::Create(si->getCaseSuccessor(0), si); > > // The switch operand is a load from the cleanup-dest alloca. > llvm::LoadInst *condition = cast<llvm::LoadInst>(si->getCondition()); > > Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=149482&r1=149481&r2=149482&view=diff > ============================================================================== > --- cfe/trunk/lib/CodeGen/CGStmt.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGStmt.cpp Wed Feb 1 01:50:21 2012 > @@ -1221,7 +1221,7 @@ > > // Update the default block in case explicit case range tests have > // been chained on top. > - SwitchInsn->setSuccessor(0, CaseRangeBlock); > + SwitchInsn->setDefaultDest(CaseRangeBlock); > > // If a default was never emitted: > if (!DefaultBlock->getParent()) { > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
