LLVM  8.0.1
Macros | Functions
LowerSwitch.cpp File Reference
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Value.h"
#include "llvm/Pass.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <iterator>
#include <limits>
#include <vector>
Include dependency graph for LowerSwitch.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "lower-switch"
 

Functions

static bool IsInRanges (const IntRange &R, const std::vector< IntRange > &Ranges)
 
 INITIALIZE_PASS (LowerSwitch, "lowerswitch", "Lower SwitchInst's to branches", false, false) FunctionPass *llvm
 
static LLVM_ATTRIBUTE_USED raw_ostreamoperator<< (raw_ostream &O, const LowerSwitch::CaseVector &C)
 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

◆ DEBUG_TYPE

#define DEBUG_TYPE   "lower-switch"

Definition at line 43 of file LowerSwitch.cpp.

Function Documentation

◆ fixPhis()

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

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 182 of file LowerSwitch.cpp.

References llvm::BasicBlock::begin(), E, llvm::BasicBlock::getFirstNonPHI(), llvm::PHINode::getIncomingBlock(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::PHINode::getNumIncomingValues(), I, llvm::ARM_PROC::IE, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::PHINode::removeIncomingValue(), llvm::reverse(), and llvm::PHINode::setIncomingBlock().

◆ INITIALIZE_PASS()

INITIALIZE_PASS ( LowerSwitch  ,
"lowerswitch"  ,
"Lower SwitchInst's to branches ,
false  ,
false   
)

◆ IsInRanges()

static bool IsInRanges ( const IntRange &  R,
const std::vector< IntRange > &  Ranges 
)
static

◆ operator<<()

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

Used for debugging purposes.

Definition at line 159 of file LowerSwitch.cpp.

References B, and E.