|
LLVM
10.0.0
|
#include "llvm/Transforms/Utils/BasicBlockUtils.h"#include "llvm/ADT/ArrayRef.h"#include "llvm/ADT/SmallPtrSet.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/Twine.h"#include "llvm/Analysis/CFG.h"#include "llvm/Analysis/DomTreeUpdater.h"#include "llvm/Analysis/LoopInfo.h"#include "llvm/Analysis/MemoryDependenceAnalysis.h"#include "llvm/Analysis/MemorySSAUpdater.h"#include "llvm/Analysis/PostDominators.h"#include "llvm/IR/BasicBlock.h"#include "llvm/IR/CFG.h"#include "llvm/IR/Constants.h"#include "llvm/IR/DebugInfoMetadata.h"#include "llvm/IR/Dominators.h"#include "llvm/IR/Function.h"#include "llvm/IR/InstrTypes.h"#include "llvm/IR/Instruction.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/LLVMContext.h"#include "llvm/IR/Type.h"#include "llvm/IR/User.h"#include "llvm/IR/Value.h"#include "llvm/IR/ValueHandle.h"#include "llvm/Support/Casting.h"#include "llvm/Support/Debug.h"#include "llvm/Support/raw_ostream.h"#include "llvm/Transforms/Utils/Local.h"#include <cassert>#include <cstdint>#include <string>#include <utility>#include <vector>Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "basicblock-utils" |
Functions | |
| static bool | removeRedundantDbgInstrsUsingBackwardScan (BasicBlock *BB) |
| Remove redundant instructions within sequences of consecutive dbg.value instructions. More... | |
| static bool | removeRedundantDbgInstrsUsingForwardScan (BasicBlock *BB) |
| Remove redundant dbg.value instructions using a forward scan. More... | |
| static void | UpdateAnalysisInformation (BasicBlock *OldBB, BasicBlock *NewBB, ArrayRef< BasicBlock *> Preds, DominatorTree *DT, LoopInfo *LI, MemorySSAUpdater *MSSAU, bool PreserveLCSSA, bool &HasLoopExit) |
| Update DominatorTree, LoopInfo, and LCCSA analysis information. More... | |
| static void | UpdatePHINodes (BasicBlock *OrigBB, BasicBlock *NewBB, ArrayRef< BasicBlock *> Preds, BranchInst *BI, bool HasLoopExit) |
| Update the PHI nodes in OrigBB to include the values coming from NewBB. More... | |
| #define DEBUG_TYPE "basicblock-utils" |
Definition at line 52 of file BasicBlockUtils.cpp.
|
static |
Remove redundant instructions within sequences of consecutive dbg.value instructions.
This is done using a backward scan to keep the last dbg.value describing a specific variable/fragment.
Given a sequence of consecutive DbgValueInst like this
dbg.value ..., "x", FragmentX1 (*) dbg.value ..., "y", FragmentY1 dbg.value ..., "x", FragmentX2 dbg.value ..., "x", FragmentX1 (**)
then the instruction marked with (*) can be removed (it is guaranteed to be obsoleted by the instruction marked with (**) as the latter instruction is describing the same variable using the same fragment info).
Possible improvements:
Definition at line 338 of file BasicBlockUtils.cpp.
References llvm::detail::DenseSetImpl< ValueT, SmallDenseMap< ValueT, detail::DenseSetEmpty, InlineBuckets, ValueInfoT, detail::DenseSetPair< ValueT > >, ValueInfoT >::clear(), I, llvm::detail::DenseSetImpl< ValueT, SmallDenseMap< ValueT, detail::DenseSetEmpty, InlineBuckets, ValueInfoT, detail::DenseSetPair< ValueT > >, ValueInfoT >::insert(), llvm::SmallVectorTemplateBase< T >::push_back(), and llvm::reverse().
Referenced by llvm::RemoveRedundantDbgInstrs().
|
static |
Remove redundant dbg.value instructions using a forward scan.
This can remove a dbg.value instruction that is redundant due to indicating that a variable has the same value as already being indicated by an earlier dbg.value.
Given two identical dbg.value instructions, separated by a block of instructions that isn't describing the same variable, like this
dbg.value X1, "x", FragmentX1 (**) <block of instructions, none being "dbg.value ..., "x", ..."> dbg.value X1, "x", FragmentX1 (*)
then the instruction marked with (*) can be removed. Variable "x" is already described as being mapped to the SSA value X1.
Possible improvements:
Definition at line 385 of file BasicBlockUtils.cpp.
References llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::find(), I, and llvm::SmallVectorTemplateBase< T >::push_back().
Referenced by llvm::RemoveRedundantDbgInstrs().
|
static |
Update DominatorTree, LoopInfo, and LCCSA analysis information.
Definition at line 552 of file BasicBlockUtils.cpp.
References llvm::LoopBase< BlockT, LoopT >::addBasicBlockToLoop(), assert(), llvm::LoopBase< BlockT, LoopT >::contains(), llvm::DomTreeNodeBase< NodeT >::getBlock(), llvm::Function::getEntryBlock(), llvm::LoopBase< BlockT, LoopT >::getLoopDepth(), llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(), llvm::BasicBlock::getParent(), llvm::LoopBase< BlockT, LoopT >::getParentLoop(), llvm::DominatorTreeBase< NodeT, IsPostDom >::getRootNode(), llvm::DominatorTree::isReachableFromEntry(), llvm::LoopBase< BlockT, LoopT >::moveToHeader(), llvm::AArch64CC::PL, llvm::DominatorTreeBase< NodeT, IsPostDom >::setNewRoot(), llvm::DominatorTreeBase< NodeT, IsPostDom >::splitBlock(), and llvm::MemorySSAUpdater::wireOldPredecessorsToNewImmediatePredecessor().
Referenced by llvm::SplitBlockPredecessors(), and llvm::SplitLandingPadPredecessors().
|
static |
Update the PHI nodes in OrigBB to include the values coming from NewBB.
This also updates AliasAnalysis, if available.
Definition at line 643 of file BasicBlockUtils.cpp.
References llvm::PHINode::addIncoming(), llvm::ArrayRef< T >::begin(), llvm::BasicBlock::begin(), llvm::PHINode::Create(), llvm::numbers::e, llvm::ArrayRef< T >::end(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::PHINode::getIncomingValueForBlock(), llvm::Value::getName(), llvm::PHINode::getNumIncomingValues(), llvm::Value::getType(), I, llvm::PHINode::removeIncomingValue(), and llvm::ArrayRef< T >::size().
Referenced by HandleInlinedEHPad(), llvm::SplitBlockPredecessors(), and llvm::SplitLandingPadPredecessors().
1.8.13