llvm-6502/lib/Transforms/IPO
Stepan Dyatkovskiy 24473120a2 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.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149481 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-01 07:49:51 +00:00
..
ArgumentPromotion.cpp Update inter-procedural optimizations for atomic load/store. 2011-08-15 22:16:46 +00:00
CMakeLists.txt build/CMake: Finish removal of add_llvm_library_dependencies. 2011-11-29 19:25:30 +00:00
ConstantMerge.cpp Re-fix the issue Bill fixed in r147899 in a slightly different way, which doesn't abuse the semantics of linker_private. We don't really want to merge any string constant with a weak_odr global. 2012-01-11 22:06:46 +00:00
DeadArgumentElimination.cpp Remove all remaining uses of Value::getNameStr(). 2011-11-15 16:27:03 +00:00
ExtractGV.cpp Improve the handling of available_externally and llvm.global_ctors. 2011-06-09 14:38:09 +00:00
FunctionAttrs.cpp SCCCaptured is trivially false on entry to this loop and not modified inside it. 2012-01-05 22:21:45 +00:00
GlobalDCE.cpp
GlobalOpt.cpp SwitchInst refactoring. 2012-02-01 07:49:51 +00:00
InlineAlways.cpp Inlining and unrolling heuristics should be aware of free truncs. 2011-10-01 01:39:05 +00:00
Inliner.cpp Refactor code from inlining and globalopt that checks whether a function definition is unused, and enhance it so it can tell that functions which are only used by a blockaddress are in fact dead. This probably doesn't happen much on most code, but the Linux kernel's _THIS_IP_ can trigger this issue with blockaddress. (GlobalDCE can also handle the given tescase, but we only run that at -O3.) Found while looking at PR11180. 2011-10-20 05:23:42 +00:00
InlineSimple.cpp Inlining and unrolling heuristics should be aware of free truncs. 2011-10-01 01:39:05 +00:00
Internalize.cpp
IPConstantPropagation.cpp land David Blaikie's patch to de-constify Type, with a few tweaks. 2011-07-18 04:54:35 +00:00
IPO.cpp C API functions must be able to see their extern "C" definitions, or it will be impossible to call them from C. 2011-08-19 01:36:54 +00:00
LLVMBuild.txt Add a basic-block autovectorization pass. 2012-02-01 03:51:43 +00:00
LoopExtractor.cpp Place the check for an exit landing pad where it will be run on both code paths through the if-then-else. 2011-09-20 22:27:16 +00:00
Makefile
MergeFunctions.cpp Update inter-procedural optimizations for atomic load/store. 2011-08-15 22:16:46 +00:00
PartialInlining.cpp Remove PHINode::reserveOperandSpace(). Instead, add a parameter to 2011-03-30 11:28:46 +00:00
PassManagerBuilder.cpp Add a basic-block autovectorization pass. 2012-02-01 03:51:43 +00:00
PruneEH.cpp Mark the SCC as "might unwind" if we run into a 'resume' instruction. 2011-08-15 18:22:00 +00:00
StripDeadPrototypes.cpp
StripSymbols.cpp switch to use the new api for structtypes. 2011-08-12 18:06:37 +00:00