LLVM: lib/CodeGen/IndirectBrExpandPass.cpp File Reference (original) (raw)
Implements an expansion pass to turn indirectbr instructions in the IR into switch instructions. More...
Implements an expansion pass to turn indirectbr instructions in the IR into switch instructions.
This works by enumerating the basic blocks in a dense range of integers, replacing each blockaddr constant with the corresponding integer constant, and then building a switch that maps from the integers to the actual blocks. All of the indirectbr instructions in the function are redirected to this common switch.
While this is generically useful if a target is unable to codegen indirectbr natively, it is primarily useful when there is some desire to get the builtin non-jump-table lowering of a switch even when the input source contained an explicit indirect branch construct.
Note that it doesn't make any sense to enable this pass unless a target also disables jump-table lowering of switches. Doing that is likely to pessimize the code.
Definition in file IndirectBrExpandPass.cpp.