LLVM  10.0.0svn
Macros | Functions | Variables
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/Analysis/AssumptionCache.h"
#include "llvm/Analysis/LazyValueInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/ConstantRange.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/KnownBits.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_BEGIN (LowerSwitch, "lowerswitch", "Lower SwitchInst's to branches", false, false) INITIALIZE_PASS_END(LowerSwitch
 
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, const unsigned NumMergedCases=std::numeric_limits< unsigned >::max())
 Update the first occurrence of the "switch statement" BB in the PHI node with the "new" BB. More...
 

Variables

 lowerswitch
 
Lower SwitchInst s to branches
 
Lower SwitchInst s to false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "lower-switch"

Definition at line 47 of file LowerSwitch.cpp.

Function Documentation

◆ fixPhis()

static void fixPhis ( BasicBlock SuccBB,
BasicBlock OrigBB,
BasicBlock NewBB,
const unsigned  NumMergedCases = std::numeric_limits<unsigned>::max() 
)
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 210 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_BEGIN()

INITIALIZE_PASS_BEGIN ( 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 185 of file LowerSwitch.cpp.

References B, and E.

Variable Documentation

◆ branches

Lower SwitchInst s to branches

Definition at line 138 of file LowerSwitch.cpp.

◆ false

Lower SwitchInst s to false

Definition at line 138 of file LowerSwitch.cpp.

◆ lowerswitch

lowerswitch

Definition at line 138 of file LowerSwitch.cpp.