LLVM
8.0.1
|
Implements an expansion pass to turn indirectbr
instructions in the IR into switch
instructions.
More...
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Sequence.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "indirectbr-expand" |
Functions | |
INITIALIZE_PASS (IndirectBrExpandPass, DEBUG_TYPE, "Expand indirectbr instructions", false, false) FunctionPass *llvm | |
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.
#define DEBUG_TYPE "indirectbr-expand" |
Definition at line 48 of file IndirectBrExpandPass.cpp.
INITIALIZE_PASS | ( | IndirectBrExpandPass | , |
DEBUG_TYPE | , | ||
"Expand indirectbr instructions" | , | ||
false | , | ||
false | |||
) |
Definition at line 69 of file IndirectBrExpandPass.cpp.
References assert(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::BasicBlock::Create(), llvm::PHINode::Create(), llvm::BranchInst::Create(), llvm::SwitchInst::Create(), llvm::CastInst::CreatePointerCast(), llvm::SmallVectorBase::empty(), llvm::Instruction::eraseFromParent(), F(), llvm::find_if(), llvm::ConstantInt::get(), llvm::IntegerType::getBitWidth(), llvm::Module::getDataLayout(), llvm::ConstantExpr::getIntToPtr(), llvm::BasicBlock::getParent(), llvm::GlobalValue::getParent(), llvm::ConstantInt::getType(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::SmallVectorTemplateBase< T >::push_back(), runOnFunction(), SI, llvm::SmallVectorBase::size(), and llvm::SystemZISD::TM.