LLVM  6.0.0svn
Macros | Functions
LowerSwitch.cpp File Reference
#include "llvm/ADT/STLExtras.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/Pass.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h"
#include <algorithm>
Include dependency graph for LowerSwitch.cpp:

Go to the source code of this file.


#define DEBUG_TYPE   "lower-switch"


static raw_ostreamoperator<< (raw_ostream &O, const LowerSwitch::CaseVector &C) LLVM_ATTRIBUTE_USED
 Used for debugging purposes. More...
static void fixPhis (BasicBlock *SuccBB, BasicBlock *OrigBB, BasicBlock *NewBB, unsigned NumMergedCases)
 Update the first occurrence of the "switch statement" BB in the PHI node with the "new" BB. More...

Macro Definition Documentation


#define DEBUG_TYPE   "lower-switch"

Definition at line 32 of file LowerSwitch.cpp.

Function Documentation

◆ fixPhis()

static void fixPhis ( BasicBlock SuccBB,
BasicBlock OrigBB,
BasicBlock NewBB,
unsigned  NumMergedCases 

Update the first occurrence of the "switch statement" BB in the PHI node with the "new" BB.

The other occurrences will:

1) Be updated by subsequent calls to this function. Switch statements may have more than one outcoming edge into the same BB if they all have the same value. When the switch statement is converted these incoming edges are now coming from multiple BBs. 2) Removed if subsequent incoming values now share the same case, i.e., multiple outcome edges are condensed into one. This is necessary to keep the number of phi values equal to the number of branches to SuccBB.

Definition at line 162 of file LowerSwitch.cpp.

References llvm::MCID::Add, assert(), llvm::BasicBlock::begin(), llvm::SwitchInst::cases(), llvm::BasicBlock::Create(), llvm::BranchInst::Create(), CreateAdd(), llvm::dbgs(), DEBUG, llvm::Default, E, llvm::WebAssembly::End, llvm::iplist_impl< IntrusiveListT, TraitsT >::erase(), llvm::Instruction::eraseFromParent(), llvm::ConstantInt::get(), llvm::ConstantExpr::getAdd(), llvm::PHINode::getBasicBlockIndex(), llvm::Function::getBasicBlockList(), llvm::SwitchInst::getCondition(), llvm::Value::getContext(), llvm::SwitchInst::getDefaultDest(), llvm::Function::getEntryBlock(), llvm::BasicBlock::getFirstNonPHI(), llvm::BasicBlock::getFirstNonPHIOrDbg(), llvm::PHINode::getIncomingBlock(), llvm::BasicBlock::getInstList(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::Value::getName(), llvm::ConstantExpr::getNeg(), llvm::SwitchInst::getNumCases(), llvm::PHINode::getNumIncomingValues(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::ConstantInt::getSExtValue(), llvm::BasicBlock::getSinglePredecessor(), High, I, llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_ULE, llvm::ARM_PROC::IE, llvm::iplist_impl< IntrusiveListT, TraitsT >::insert(), llvm::SmallPtrSetImpl< PtrType >::insert(), N, llvm::pred_begin(), llvm::pred_empty(), llvm::pred_end(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::iplist_impl< IntrusiveListT, TraitsT >::push_back(), llvm::remove_if(), llvm::PHINode::removeIncomingValue(), llvm::reverse(), llvm::PHINode::setIncomingBlock(), SI, llvm::AMDGPU::HSAMD::Kernel::Arg::Key::Size, and llvm::parallel::sort().

◆ operator<<()

static raw_ostream & operator<< ( raw_ostream O,
const LowerSwitch::CaseVector &  C 

Used for debugging purposes.

Definition at line 139 of file LowerSwitch.cpp.

References B, and E.