mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
[Analysis] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 308936
This commit is contained in:
parent
3177ae0e4a
commit
e6b6190949
@ -18,36 +18,46 @@
|
||||
#define LLVM_ANALYSIS_ALIASSETTRACKER_H
|
||||
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/DenseMapInfo.h"
|
||||
#include "llvm/ADT/ilist.h"
|
||||
#include "llvm/ADT/ilist_node.h"
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
#include "llvm/IR/Instruction.h"
|
||||
#include "llvm/IR/Metadata.h"
|
||||
#include "llvm/IR/ValueHandle.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class AliasSetTracker;
|
||||
class BasicBlock;
|
||||
class LoadInst;
|
||||
class MemSetInst;
|
||||
class MemTransferInst;
|
||||
class raw_ostream;
|
||||
class StoreInst;
|
||||
class VAArgInst;
|
||||
class MemSetInst;
|
||||
class AliasSetTracker;
|
||||
class AliasSet;
|
||||
class Value;
|
||||
|
||||
class AliasSet : public ilist_node<AliasSet> {
|
||||
friend class AliasSetTracker;
|
||||
|
||||
class PointerRec {
|
||||
Value *Val; // The pointer this record corresponds to.
|
||||
PointerRec **PrevInList, *NextInList;
|
||||
AliasSet *AS;
|
||||
uint64_t Size;
|
||||
PointerRec **PrevInList = nullptr;
|
||||
PointerRec *NextInList = nullptr;
|
||||
AliasSet *AS = nullptr;
|
||||
uint64_t Size = 0;
|
||||
AAMDNodes AAInfo;
|
||||
|
||||
public:
|
||||
PointerRec(Value *V)
|
||||
: Val(V), PrevInList(nullptr), NextInList(nullptr), AS(nullptr), Size(0),
|
||||
AAInfo(DenseMapInfo<AAMDNodes>::getEmptyKey()) {}
|
||||
: Val(V), AAInfo(DenseMapInfo<AAMDNodes>::getEmptyKey()) {}
|
||||
|
||||
Value *getValue() const { return Val; }
|
||||
|
||||
@ -121,9 +131,10 @@ class AliasSet : public ilist_node<AliasSet> {
|
||||
};
|
||||
|
||||
// Doubly linked list of nodes.
|
||||
PointerRec *PtrList, **PtrListEnd;
|
||||
PointerRec *PtrList = nullptr;
|
||||
PointerRec **PtrListEnd;
|
||||
// Forwarding pointer.
|
||||
AliasSet *Forward;
|
||||
AliasSet *Forward = nullptr;
|
||||
|
||||
/// All instructions without a specific address in this alias set.
|
||||
/// In rare cases this vector can have a null'ed out WeakVH
|
||||
@ -167,7 +178,7 @@ class AliasSet : public ilist_node<AliasSet> {
|
||||
/// True if this alias set contains volatile loads or stores.
|
||||
unsigned Volatile : 1;
|
||||
|
||||
unsigned SetSize;
|
||||
unsigned SetSize = 0;
|
||||
|
||||
void addRef() { ++RefCount; }
|
||||
|
||||
@ -183,6 +194,9 @@ class AliasSet : public ilist_node<AliasSet> {
|
||||
}
|
||||
|
||||
public:
|
||||
AliasSet(const AliasSet &) = delete;
|
||||
AliasSet &operator=(const AliasSet &) = delete;
|
||||
|
||||
/// Accessors...
|
||||
bool isRef() const { return Access & RefAccess; }
|
||||
bool isMod() const { return Access & ModAccess; }
|
||||
@ -249,12 +263,8 @@ public:
|
||||
private:
|
||||
// Can only be created by AliasSetTracker.
|
||||
AliasSet()
|
||||
: PtrList(nullptr), PtrListEnd(&PtrList), Forward(nullptr), RefCount(0),
|
||||
AliasAny(false), Access(NoAccess), Alias(SetMustAlias),
|
||||
Volatile(false), SetSize(0) {}
|
||||
|
||||
AliasSet(const AliasSet &AS) = delete;
|
||||
void operator=(const AliasSet &AS) = delete;
|
||||
: PtrListEnd(&PtrList), RefCount(0), AliasAny(false), Access(NoAccess),
|
||||
Alias(SetMustAlias), Volatile(false) {}
|
||||
|
||||
PointerRec *getSomePointer() const {
|
||||
return PtrList;
|
||||
@ -281,6 +291,7 @@ private:
|
||||
const AAMDNodes &AAInfo,
|
||||
bool KnownMustAlias = false);
|
||||
void addUnknownInst(Instruction *I, AliasAnalysis &AA);
|
||||
|
||||
void removeUnknownInst(AliasSetTracker &AST, Instruction *I) {
|
||||
bool WasEmpty = UnknownInsts.empty();
|
||||
for (size_t i = 0, e = UnknownInsts.size(); i != e; ++i)
|
||||
@ -292,6 +303,7 @@ private:
|
||||
if (!WasEmpty && UnknownInsts.empty())
|
||||
dropRef(AST);
|
||||
}
|
||||
|
||||
void setVolatile() { Volatile = true; }
|
||||
|
||||
public:
|
||||
@ -312,11 +324,13 @@ class AliasSetTracker {
|
||||
/// Value is deleted.
|
||||
class ASTCallbackVH final : public CallbackVH {
|
||||
AliasSetTracker *AST;
|
||||
|
||||
void deleted() override;
|
||||
void allUsesReplacedWith(Value *) override;
|
||||
|
||||
public:
|
||||
ASTCallbackVH(Value *V, AliasSetTracker *AST = nullptr);
|
||||
|
||||
ASTCallbackVH &operator=(Value *V);
|
||||
};
|
||||
/// Traits to tell DenseMap that tell us how to compare and hash the value
|
||||
@ -326,9 +340,8 @@ class AliasSetTracker {
|
||||
AliasAnalysis &AA;
|
||||
ilist<AliasSet> AliasSets;
|
||||
|
||||
typedef DenseMap<ASTCallbackVH, AliasSet::PointerRec*,
|
||||
ASTCallbackVHDenseMapInfo>
|
||||
PointerMapType;
|
||||
using PointerMapType = DenseMap<ASTCallbackVH, AliasSet::PointerRec *,
|
||||
ASTCallbackVHDenseMapInfo>;
|
||||
|
||||
// Map from pointers to their node
|
||||
PointerMapType PointerMap;
|
||||
@ -336,8 +349,7 @@ class AliasSetTracker {
|
||||
public:
|
||||
/// Create an empty collection of AliasSets, and use the specified alias
|
||||
/// analysis object to disambiguate load and store addresses.
|
||||
explicit AliasSetTracker(AliasAnalysis &aa)
|
||||
: AA(aa), TotalMayAliasSetSize(0), AliasAnyAS(nullptr) {}
|
||||
explicit AliasSetTracker(AliasAnalysis &aa) : AA(aa) {}
|
||||
~AliasSetTracker() { clear(); }
|
||||
|
||||
/// These methods are used to add different types of instructions to the alias
|
||||
@ -401,8 +413,8 @@ public:
|
||||
/// tracker already knows about a value, it will ignore the request.
|
||||
void copyValue(Value *From, Value *To);
|
||||
|
||||
typedef ilist<AliasSet>::iterator iterator;
|
||||
typedef ilist<AliasSet>::const_iterator const_iterator;
|
||||
using iterator = ilist<AliasSet>::iterator;
|
||||
using const_iterator = ilist<AliasSet>::const_iterator;
|
||||
|
||||
const_iterator begin() const { return AliasSets.begin(); }
|
||||
const_iterator end() const { return AliasSets.end(); }
|
||||
@ -417,11 +429,11 @@ private:
|
||||
friend class AliasSet;
|
||||
|
||||
// The total number of pointers contained in all "may" alias sets.
|
||||
unsigned TotalMayAliasSetSize;
|
||||
unsigned TotalMayAliasSetSize = 0;
|
||||
|
||||
// A non-null value signifies this AST is saturated. A saturated AST lumps
|
||||
// all pointers into a single "May" set.
|
||||
AliasSet *AliasAnyAS;
|
||||
AliasSet *AliasAnyAS = nullptr;
|
||||
|
||||
void removeAliasSet(AliasSet *AS);
|
||||
|
||||
@ -451,6 +463,6 @@ inline raw_ostream& operator<<(raw_ostream &OS, const AliasSetTracker &AST) {
|
||||
return OS;
|
||||
}
|
||||
|
||||
} // End llvm namespace
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
#endif // LLVM_ANALYSIS_ALIASSETTRACKER_H
|
||||
|
@ -54,13 +54,17 @@
|
||||
#include "llvm/IR/PassManager.h"
|
||||
#include "llvm/IR/ValueHandle.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include <cassert>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class Function;
|
||||
class Module;
|
||||
class CallGraphNode;
|
||||
class Module;
|
||||
class raw_ostream;
|
||||
|
||||
/// \brief The basic data container for the call graph of a \c Module of IR.
|
||||
///
|
||||
@ -70,8 +74,8 @@ class CallGraphNode;
|
||||
class CallGraph {
|
||||
Module &M;
|
||||
|
||||
typedef std::map<const Function *, std::unique_ptr<CallGraphNode>>
|
||||
FunctionMapTy;
|
||||
using FunctionMapTy =
|
||||
std::map<const Function *, std::unique_ptr<CallGraphNode>>;
|
||||
|
||||
/// \brief A map from \c Function* to \c CallGraphNode*.
|
||||
FunctionMapTy FunctionMap;
|
||||
@ -103,8 +107,8 @@ public:
|
||||
void print(raw_ostream &OS) const;
|
||||
void dump() const;
|
||||
|
||||
typedef FunctionMapTy::iterator iterator;
|
||||
typedef FunctionMapTy::const_iterator const_iterator;
|
||||
using iterator = FunctionMapTy::iterator;
|
||||
using const_iterator = FunctionMapTy::const_iterator;
|
||||
|
||||
/// \brief Returns the module the call graph corresponds to.
|
||||
Module &getModule() const { return M; }
|
||||
@ -162,20 +166,23 @@ class CallGraphNode {
|
||||
public:
|
||||
/// \brief A pair of the calling instruction (a call or invoke)
|
||||
/// and the call graph node being called.
|
||||
typedef std::pair<WeakTrackingVH, CallGraphNode *> CallRecord;
|
||||
using CallRecord = std::pair<WeakTrackingVH, CallGraphNode *>;
|
||||
|
||||
public:
|
||||
typedef std::vector<CallRecord> CalledFunctionsVector;
|
||||
using CalledFunctionsVector = std::vector<CallRecord>;
|
||||
|
||||
/// \brief Creates a node for the specified function.
|
||||
inline CallGraphNode(Function *F) : F(F), NumReferences(0) {}
|
||||
inline CallGraphNode(Function *F) : F(F) {}
|
||||
|
||||
CallGraphNode(const CallGraphNode &) = delete;
|
||||
CallGraphNode &operator=(const CallGraphNode &) = delete;
|
||||
|
||||
~CallGraphNode() {
|
||||
assert(NumReferences == 0 && "Node deleted while references remain");
|
||||
}
|
||||
|
||||
typedef std::vector<CallRecord>::iterator iterator;
|
||||
typedef std::vector<CallRecord>::const_iterator const_iterator;
|
||||
using iterator = std::vector<CallRecord>::iterator;
|
||||
using const_iterator = std::vector<CallRecord>::const_iterator;
|
||||
|
||||
/// \brief Returns the function that this call graph node represents.
|
||||
Function *getFunction() const { return F; }
|
||||
@ -268,10 +275,7 @@ private:
|
||||
|
||||
/// \brief The number of times that this CallGraphNode occurs in the
|
||||
/// CalledFunctions array of this or other CallGraphNodes.
|
||||
unsigned NumReferences;
|
||||
|
||||
CallGraphNode(const CallGraphNode &) = delete;
|
||||
void operator=(const CallGraphNode &) = delete;
|
||||
unsigned NumReferences = 0;
|
||||
|
||||
void DropRef() { --NumReferences; }
|
||||
void AddRef() { ++NumReferences; }
|
||||
@ -287,11 +291,12 @@ private:
|
||||
/// resulting data.
|
||||
class CallGraphAnalysis : public AnalysisInfoMixin<CallGraphAnalysis> {
|
||||
friend AnalysisInfoMixin<CallGraphAnalysis>;
|
||||
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
/// \brief A formulaic typedef to inform clients of the result type.
|
||||
typedef CallGraph Result;
|
||||
/// \brief A formulaic type to inform clients of the result type.
|
||||
using Result = CallGraph;
|
||||
|
||||
/// \brief Compute the \c CallGraph for the module \c M.
|
||||
///
|
||||
@ -305,6 +310,7 @@ class CallGraphPrinterPass : public PassInfoMixin<CallGraphPrinterPass> {
|
||||
|
||||
public:
|
||||
explicit CallGraphPrinterPass(raw_ostream &OS) : OS(OS) {}
|
||||
|
||||
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
|
||||
};
|
||||
|
||||
@ -329,8 +335,8 @@ public:
|
||||
const CallGraph &getCallGraph() const { return *G; }
|
||||
CallGraph &getCallGraph() { return *G; }
|
||||
|
||||
typedef CallGraph::iterator iterator;
|
||||
typedef CallGraph::const_iterator const_iterator;
|
||||
using iterator = CallGraph::iterator;
|
||||
using const_iterator = CallGraph::const_iterator;
|
||||
|
||||
/// \brief Returns the module the call graph corresponds to.
|
||||
Module &getModule() const { return G->getModule(); }
|
||||
@ -399,40 +405,38 @@ public:
|
||||
// Provide graph traits for tranversing call graphs using standard graph
|
||||
// traversals.
|
||||
template <> struct GraphTraits<CallGraphNode *> {
|
||||
typedef CallGraphNode *NodeRef;
|
||||
|
||||
typedef CallGraphNode::CallRecord CGNPairTy;
|
||||
using NodeRef = CallGraphNode *;
|
||||
using CGNPairTy = CallGraphNode::CallRecord;
|
||||
|
||||
static NodeRef getEntryNode(CallGraphNode *CGN) { return CGN; }
|
||||
|
||||
static CallGraphNode *CGNGetValue(CGNPairTy P) { return P.second; }
|
||||
|
||||
typedef mapped_iterator<CallGraphNode::iterator, decltype(&CGNGetValue)>
|
||||
ChildIteratorType;
|
||||
using ChildIteratorType =
|
||||
mapped_iterator<CallGraphNode::iterator, decltype(&CGNGetValue)>;
|
||||
|
||||
static ChildIteratorType child_begin(NodeRef N) {
|
||||
return ChildIteratorType(N->begin(), &CGNGetValue);
|
||||
}
|
||||
|
||||
static ChildIteratorType child_end(NodeRef N) {
|
||||
return ChildIteratorType(N->end(), &CGNGetValue);
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct GraphTraits<const CallGraphNode *> {
|
||||
typedef const CallGraphNode *NodeRef;
|
||||
|
||||
typedef CallGraphNode::CallRecord CGNPairTy;
|
||||
using NodeRef = const CallGraphNode *;
|
||||
using CGNPairTy = CallGraphNode::CallRecord;
|
||||
|
||||
static NodeRef getEntryNode(const CallGraphNode *CGN) { return CGN; }
|
||||
|
||||
static const CallGraphNode *CGNGetValue(CGNPairTy P) { return P.second; }
|
||||
|
||||
typedef mapped_iterator<CallGraphNode::const_iterator, decltype(&CGNGetValue)>
|
||||
ChildIteratorType;
|
||||
using ChildIteratorType =
|
||||
mapped_iterator<CallGraphNode::const_iterator, decltype(&CGNGetValue)>;
|
||||
|
||||
static ChildIteratorType child_begin(NodeRef N) {
|
||||
return ChildIteratorType(N->begin(), &CGNGetValue);
|
||||
}
|
||||
|
||||
static ChildIteratorType child_end(NodeRef N) {
|
||||
return ChildIteratorType(N->end(), &CGNGetValue);
|
||||
}
|
||||
@ -440,21 +444,25 @@ template <> struct GraphTraits<const CallGraphNode *> {
|
||||
|
||||
template <>
|
||||
struct GraphTraits<CallGraph *> : public GraphTraits<CallGraphNode *> {
|
||||
using PairTy =
|
||||
std::pair<const Function *const, std::unique_ptr<CallGraphNode>>;
|
||||
|
||||
static NodeRef getEntryNode(CallGraph *CGN) {
|
||||
return CGN->getExternalCallingNode(); // Start at the external node!
|
||||
}
|
||||
typedef std::pair<const Function *const, std::unique_ptr<CallGraphNode>>
|
||||
PairTy;
|
||||
|
||||
static CallGraphNode *CGGetValuePtr(const PairTy &P) {
|
||||
return P.second.get();
|
||||
}
|
||||
|
||||
// nodes_iterator/begin/end - Allow iteration over all nodes in the graph
|
||||
typedef mapped_iterator<CallGraph::iterator, decltype(&CGGetValuePtr)>
|
||||
nodes_iterator;
|
||||
using nodes_iterator =
|
||||
mapped_iterator<CallGraph::iterator, decltype(&CGGetValuePtr)>;
|
||||
|
||||
static nodes_iterator nodes_begin(CallGraph *CG) {
|
||||
return nodes_iterator(CG->begin(), &CGGetValuePtr);
|
||||
}
|
||||
|
||||
static nodes_iterator nodes_end(CallGraph *CG) {
|
||||
return nodes_iterator(CG->end(), &CGGetValuePtr);
|
||||
}
|
||||
@ -463,26 +471,30 @@ struct GraphTraits<CallGraph *> : public GraphTraits<CallGraphNode *> {
|
||||
template <>
|
||||
struct GraphTraits<const CallGraph *> : public GraphTraits<
|
||||
const CallGraphNode *> {
|
||||
using PairTy =
|
||||
std::pair<const Function *const, std::unique_ptr<CallGraphNode>>;
|
||||
|
||||
static NodeRef getEntryNode(const CallGraph *CGN) {
|
||||
return CGN->getExternalCallingNode(); // Start at the external node!
|
||||
}
|
||||
typedef std::pair<const Function *const, std::unique_ptr<CallGraphNode>>
|
||||
PairTy;
|
||||
|
||||
static const CallGraphNode *CGGetValuePtr(const PairTy &P) {
|
||||
return P.second.get();
|
||||
}
|
||||
|
||||
// nodes_iterator/begin/end - Allow iteration over all nodes in the graph
|
||||
typedef mapped_iterator<CallGraph::const_iterator, decltype(&CGGetValuePtr)>
|
||||
nodes_iterator;
|
||||
using nodes_iterator =
|
||||
mapped_iterator<CallGraph::const_iterator, decltype(&CGGetValuePtr)>;
|
||||
|
||||
static nodes_iterator nodes_begin(const CallGraph *CG) {
|
||||
return nodes_iterator(CG->begin(), &CGGetValuePtr);
|
||||
}
|
||||
|
||||
static nodes_iterator nodes_end(const CallGraph *CG) {
|
||||
return nodes_iterator(CG->end(), &CGGetValuePtr);
|
||||
}
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
#endif // LLVM_ANALYSIS_CALLGRAPH_H
|
||||
|
@ -18,37 +18,44 @@
|
||||
#ifndef LLVM_ANALYSIS_DOMINANCEFRONTIER_H
|
||||
#define LLVM_ANALYSIS_DOMINANCEFRONTIER_H
|
||||
|
||||
#include "llvm/IR/Dominators.h"
|
||||
#include "llvm/ADT/GraphTraits.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Support/GenericDomTree.h"
|
||||
#include <cassert>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class Function;
|
||||
class raw_ostream;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// DominanceFrontierBase - Common base class for computing forward and inverse
|
||||
/// dominance frontiers for a function.
|
||||
///
|
||||
template <class BlockT, bool IsPostDom>
|
||||
class DominanceFrontierBase {
|
||||
public:
|
||||
typedef std::set<BlockT *> DomSetType; // Dom set for a bb
|
||||
typedef std::map<BlockT *, DomSetType> DomSetMapType; // Dom set map
|
||||
public:
|
||||
using DomSetType = std::set<BlockT *>; // Dom set for a bb
|
||||
using DomSetMapType = std::map<BlockT *, DomSetType>; // Dom set map
|
||||
|
||||
protected:
|
||||
typedef GraphTraits<BlockT *> BlockTraits;
|
||||
using BlockTraits = GraphTraits<BlockT *>;
|
||||
|
||||
DomSetMapType Frontiers;
|
||||
std::vector<BlockT *> Roots;
|
||||
static constexpr bool IsPostDominators = IsPostDom;
|
||||
|
||||
public:
|
||||
DominanceFrontierBase() {}
|
||||
public:
|
||||
DominanceFrontierBase() = default;
|
||||
|
||||
/// getRoots - Return the root blocks of the current CFG. This may include
|
||||
/// multiple blocks if we are computing post dominators. For forward
|
||||
/// dominators, this will always be a single block (the entry node).
|
||||
///
|
||||
inline const std::vector<BlockT *> &getRoots() const {
|
||||
return Roots;
|
||||
}
|
||||
@ -59,7 +66,6 @@ protected:
|
||||
}
|
||||
|
||||
/// isPostDominator - Returns true if analysis based of postdoms
|
||||
///
|
||||
bool isPostDominator() const {
|
||||
return IsPostDominators;
|
||||
}
|
||||
@ -69,8 +75,9 @@ protected:
|
||||
}
|
||||
|
||||
// Accessor interface:
|
||||
typedef typename DomSetMapType::iterator iterator;
|
||||
typedef typename DomSetMapType::const_iterator const_iterator;
|
||||
using iterator = typename DomSetMapType::iterator;
|
||||
using const_iterator = typename DomSetMapType::const_iterator;
|
||||
|
||||
iterator begin() { return Frontiers.begin(); }
|
||||
const_iterator begin() const { return Frontiers.begin(); }
|
||||
iterator end() { return Frontiers.end(); }
|
||||
@ -115,19 +122,19 @@ protected:
|
||||
template <class BlockT>
|
||||
class ForwardDominanceFrontierBase
|
||||
: public DominanceFrontierBase<BlockT, false> {
|
||||
private:
|
||||
typedef GraphTraits<BlockT *> BlockTraits;
|
||||
private:
|
||||
using BlockTraits = GraphTraits<BlockT *>;
|
||||
|
||||
public:
|
||||
typedef DomTreeBase<BlockT> DomTreeT;
|
||||
typedef DomTreeNodeBase<BlockT> DomTreeNodeT;
|
||||
typedef typename DominanceFrontierBase<BlockT, false>::DomSetType DomSetType;
|
||||
using DomTreeT = DomTreeBase<BlockT>;
|
||||
using DomTreeNodeT = DomTreeNodeBase<BlockT>;
|
||||
using DomSetType = typename DominanceFrontierBase<BlockT, false>::DomSetType;
|
||||
|
||||
void analyze(DomTreeT &DT) {
|
||||
this->Roots = DT.getRoots();
|
||||
assert(this->Roots.size() == 1 &&
|
||||
"Only one entry block for forward domfronts!");
|
||||
calculate(DT, DT[this->Roots[0]]);
|
||||
void analyze(DomTreeT &DT) {
|
||||
this->Roots = DT.getRoots();
|
||||
assert(this->Roots.size() == 1 &&
|
||||
"Only one entry block for forward domfronts!");
|
||||
calculate(DT, DT[this->Roots[0]]);
|
||||
}
|
||||
|
||||
const DomSetType &calculate(const DomTreeT &DT, const DomTreeNodeT *Node);
|
||||
@ -135,20 +142,21 @@ public:
|
||||
|
||||
class DominanceFrontier : public ForwardDominanceFrontierBase<BasicBlock> {
|
||||
public:
|
||||
typedef DomTreeBase<BasicBlock> DomTreeT;
|
||||
typedef DomTreeNodeBase<BasicBlock> DomTreeNodeT;
|
||||
typedef DominanceFrontierBase<BasicBlock, false>::DomSetType DomSetType;
|
||||
typedef DominanceFrontierBase<BasicBlock, false>::iterator iterator;
|
||||
typedef DominanceFrontierBase<BasicBlock, false>::const_iterator
|
||||
const_iterator;
|
||||
using DomTreeT = DomTreeBase<BasicBlock>;
|
||||
using DomTreeNodeT = DomTreeNodeBase<BasicBlock>;
|
||||
using DomSetType = DominanceFrontierBase<BasicBlock, false>::DomSetType;
|
||||
using iterator = DominanceFrontierBase<BasicBlock, false>::iterator;
|
||||
using const_iterator =
|
||||
DominanceFrontierBase<BasicBlock, false>::const_iterator;
|
||||
|
||||
/// Handle invalidation explicitly.
|
||||
bool invalidate(Function &F, const PreservedAnalyses &PA,
|
||||
FunctionAnalysisManager::Invalidator &);
|
||||
/// Handle invalidation explicitly.
|
||||
bool invalidate(Function &F, const PreservedAnalyses &PA,
|
||||
FunctionAnalysisManager::Invalidator &);
|
||||
};
|
||||
|
||||
class DominanceFrontierWrapperPass : public FunctionPass {
|
||||
DominanceFrontier DF;
|
||||
|
||||
public:
|
||||
static char ID; // Pass ID, replacement for typeid
|
||||
|
||||
@ -176,11 +184,12 @@ extern template class ForwardDominanceFrontierBase<BasicBlock>;
|
||||
class DominanceFrontierAnalysis
|
||||
: public AnalysisInfoMixin<DominanceFrontierAnalysis> {
|
||||
friend AnalysisInfoMixin<DominanceFrontierAnalysis>;
|
||||
|
||||
static AnalysisKey Key;
|
||||
|
||||
public:
|
||||
/// \brief Provide the result typedef for this analysis pass.
|
||||
typedef DominanceFrontier Result;
|
||||
/// \brief Provide the result type for this analysis pass.
|
||||
using Result = DominanceFrontier;
|
||||
|
||||
/// \brief Run the analysis pass over a function and produce a dominator tree.
|
||||
DominanceFrontier run(Function &F, FunctionAnalysisManager &AM);
|
||||
@ -193,9 +202,10 @@ class DominanceFrontierPrinterPass
|
||||
|
||||
public:
|
||||
explicit DominanceFrontierPrinterPass(raw_ostream &OS);
|
||||
|
||||
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
#endif // LLVM_ANALYSIS_DOMINANCEFRONTIER_H
|
||||
|
@ -18,21 +18,28 @@
|
||||
#ifndef LLVM_ANALYSIS_DOMINANCEFRONTIERIMPL_H
|
||||
#define LLVM_ANALYSIS_DOMINANCEFRONTIERIMPL_H
|
||||
|
||||
#include "llvm/ADT/GraphTraits.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/Analysis/DominanceFrontier.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/GenericDomTree.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <cassert>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
template <class BlockT>
|
||||
class DFCalculateWorkObject {
|
||||
public:
|
||||
typedef DomTreeNodeBase<BlockT> DomTreeNodeT;
|
||||
using DomTreeNodeT = DomTreeNodeBase<BlockT>;
|
||||
|
||||
DFCalculateWorkObject(BlockT *B, BlockT *P, const DomTreeNodeT *N,
|
||||
const DomTreeNodeT *PN)
|
||||
: currentBB(B), parentBB(P), Node(N), parentNode(PN) {}
|
||||
|
||||
BlockT *currentBB;
|
||||
BlockT *parentBB;
|
||||
const DomTreeNodeT *Node;
|
||||
@ -219,6 +226,6 @@ ForwardDominanceFrontierBase<BlockT>::calculate(const DomTreeT &DT,
|
||||
return *Result;
|
||||
}
|
||||
|
||||
} // End llvm namespace
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
#endif // LLVM_ANALYSIS_DOMINANCEFRONTIERIMPL_H
|
||||
|
@ -39,10 +39,11 @@ class Interval {
|
||||
/// interval. Also, any loops in this interval must go through the HeaderNode.
|
||||
///
|
||||
BasicBlock *HeaderNode;
|
||||
|
||||
public:
|
||||
typedef std::vector<BasicBlock*>::iterator succ_iterator;
|
||||
typedef std::vector<BasicBlock*>::iterator pred_iterator;
|
||||
typedef std::vector<BasicBlock*>::iterator node_iterator;
|
||||
using succ_iterator = std::vector<BasicBlock*>::iterator;
|
||||
using pred_iterator = std::vector<BasicBlock*>::iterator;
|
||||
using node_iterator = std::vector<BasicBlock*>::iterator;
|
||||
|
||||
inline Interval(BasicBlock *Header) : HeaderNode(Header) {
|
||||
Nodes.push_back(Header);
|
||||
@ -51,18 +52,15 @@ public:
|
||||
inline BasicBlock *getHeaderNode() const { return HeaderNode; }
|
||||
|
||||
/// Nodes - The basic blocks in this interval.
|
||||
///
|
||||
std::vector<BasicBlock*> Nodes;
|
||||
|
||||
/// Successors - List of BasicBlocks that are reachable directly from nodes in
|
||||
/// this interval, but are not in the interval themselves.
|
||||
/// These nodes necessarily must be header nodes for other intervals.
|
||||
///
|
||||
std::vector<BasicBlock*> Successors;
|
||||
|
||||
/// Predecessors - List of BasicBlocks that have this Interval's header block
|
||||
/// as one of their successors.
|
||||
///
|
||||
std::vector<BasicBlock*> Predecessors;
|
||||
|
||||
/// contains - Find out if a basic block is in this interval
|
||||
@ -88,7 +86,6 @@ public:
|
||||
/// Equality operator. It is only valid to compare two intervals from the
|
||||
/// same partition, because of this, all we have to check is the header node
|
||||
/// for equality.
|
||||
///
|
||||
inline bool operator==(const Interval &I) const {
|
||||
return HeaderNode == I.HeaderNode;
|
||||
}
|
||||
@ -121,8 +118,8 @@ inline Interval::pred_iterator pred_end(Interval *I) {
|
||||
}
|
||||
|
||||
template <> struct GraphTraits<Interval*> {
|
||||
typedef Interval *NodeRef;
|
||||
typedef Interval::succ_iterator ChildIteratorType;
|
||||
using NodeRef = Interval *;
|
||||
using ChildIteratorType = Interval::succ_iterator;
|
||||
|
||||
static NodeRef getEntryNode(Interval *I) { return I; }
|
||||
|
||||
@ -131,14 +128,15 @@ template <> struct GraphTraits<Interval*> {
|
||||
static ChildIteratorType child_end(NodeRef N) { return succ_end(N); }
|
||||
};
|
||||
|
||||
template <> struct GraphTraits<Inverse<Interval*> > {
|
||||
typedef Interval *NodeRef;
|
||||
typedef Interval::pred_iterator ChildIteratorType;
|
||||
template <> struct GraphTraits<Inverse<Interval*>> {
|
||||
using NodeRef = Interval *;
|
||||
using ChildIteratorType = Interval::pred_iterator;
|
||||
|
||||
static NodeRef getEntryNode(Inverse<Interval *> G) { return G.Graph; }
|
||||
static ChildIteratorType child_begin(NodeRef N) { return pred_begin(N); }
|
||||
static ChildIteratorType child_end(NodeRef N) { return pred_end(N); }
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
#endif // LLVM_ANALYSIS_INTERVAL_H
|
||||
|
@ -33,26 +33,32 @@
|
||||
#ifndef LLVM_ANALYSIS_INTERVALITERATOR_H
|
||||
#define LLVM_ANALYSIS_INTERVALITERATOR_H
|
||||
|
||||
#include "llvm/ADT/GraphTraits.h"
|
||||
#include "llvm/Analysis/Interval.h"
|
||||
#include "llvm/Analysis/IntervalPartition.h"
|
||||
#include "llvm/IR/CFG.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <iterator>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class BasicBlock;
|
||||
|
||||
// getNodeHeader - Given a source graph node and the source graph, return the
|
||||
// BasicBlock that is the header node. This is the opposite of
|
||||
// getSourceGraphNode.
|
||||
//
|
||||
inline BasicBlock *getNodeHeader(BasicBlock *BB) { return BB; }
|
||||
inline BasicBlock *getNodeHeader(Interval *I) { return I->getHeaderNode(); }
|
||||
|
||||
// getSourceGraphNode - Given a BasicBlock and the source graph, return the
|
||||
// source graph node that corresponds to the BasicBlock. This is the opposite
|
||||
// of getNodeHeader.
|
||||
//
|
||||
inline BasicBlock *getSourceGraphNode(Function *, BasicBlock *BB) {
|
||||
return BB;
|
||||
}
|
||||
@ -64,7 +70,6 @@ inline Interval *getSourceGraphNode(IntervalPartition *IP, BasicBlock *BB) {
|
||||
// with the task of adding a node to the new interval, depending on the
|
||||
// type of the source node. In the case of a CFG source graph (BasicBlock
|
||||
// case), the BasicBlock itself is added to the interval.
|
||||
//
|
||||
inline void addNodeToInterval(Interval *Int, BasicBlock *BB) {
|
||||
Int->Nodes.push_back(BB);
|
||||
}
|
||||
@ -75,28 +80,25 @@ inline void addNodeToInterval(Interval *Int, BasicBlock *BB) {
|
||||
// case), the BasicBlock itself is added to the interval. In the case of
|
||||
// an IntervalPartition source graph (Interval case), all of the member
|
||||
// BasicBlocks are added to the interval.
|
||||
//
|
||||
inline void addNodeToInterval(Interval *Int, Interval *I) {
|
||||
// Add all of the nodes in I as new nodes in Int.
|
||||
Int->Nodes.insert(Int->Nodes.end(), I->Nodes.begin(), I->Nodes.end());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template<class NodeTy, class OrigContainer_t, class GT = GraphTraits<NodeTy*>,
|
||||
class IGT = GraphTraits<Inverse<NodeTy*> > >
|
||||
template<class NodeTy, class OrigContainer_t, class GT = GraphTraits<NodeTy *>,
|
||||
class IGT = GraphTraits<Inverse<NodeTy *>>>
|
||||
class IntervalIterator {
|
||||
std::vector<std::pair<Interval*, typename Interval::succ_iterator> > IntStack;
|
||||
std::set<BasicBlock*> Visited;
|
||||
std::vector<std::pair<Interval *, typename Interval::succ_iterator>> IntStack;
|
||||
std::set<BasicBlock *> Visited;
|
||||
OrigContainer_t *OrigContainer;
|
||||
bool IOwnMem; // If True, delete intervals when done with them
|
||||
// See file header for conditions of use
|
||||
public:
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
|
||||
IntervalIterator() {} // End iterator, empty stack
|
||||
public:
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
|
||||
IntervalIterator() = default; // End iterator, empty stack
|
||||
|
||||
IntervalIterator(Function *M, bool OwnMemory) : IOwnMem(OwnMemory) {
|
||||
OrigContainer = M;
|
||||
if (!ProcessInterval(&M->front())) {
|
||||
@ -157,6 +159,7 @@ public:
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
IntervalIterator operator++(int) { // Postincrement
|
||||
IntervalIterator tmp = *this;
|
||||
++*this;
|
||||
@ -171,7 +174,6 @@ private:
|
||||
//
|
||||
// This method is templated because it may operate on two different source
|
||||
// graphs: a basic block graph, or a preexisting interval graph.
|
||||
//
|
||||
bool ProcessInterval(NodeTy *Node) {
|
||||
BasicBlock *Header = getNodeHeader(Node);
|
||||
if (!Visited.insert(Header).second)
|
||||
@ -196,7 +198,6 @@ private:
|
||||
//
|
||||
// This method is templated because it may operate on two different source
|
||||
// graphs: a basic block graph, or a preexisting interval graph.
|
||||
//
|
||||
void ProcessNode(Interval *Int, NodeTy *Node) {
|
||||
assert(Int && "Null interval == bad!");
|
||||
assert(Node && "Null Node == bad!");
|
||||
@ -241,10 +242,9 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
typedef IntervalIterator<BasicBlock, Function> function_interval_iterator;
|
||||
typedef IntervalIterator<Interval, IntervalPartition>
|
||||
interval_part_interval_iterator;
|
||||
|
||||
using function_interval_iterator = IntervalIterator<BasicBlock, Function>;
|
||||
using interval_part_interval_iterator =
|
||||
IntervalIterator<Interval, IntervalPartition>;
|
||||
|
||||
inline function_interval_iterator intervals_begin(Function *F,
|
||||
bool DeleteInts = true) {
|
||||
@ -263,6 +263,6 @@ inline interval_part_interval_iterator intervals_end(IntervalPartition &IP) {
|
||||
return interval_part_interval_iterator();
|
||||
}
|
||||
|
||||
} // End llvm namespace
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
#endif // LLVM_ANALYSIS_INTERVALITERATOR_H
|
||||
|
@ -23,12 +23,15 @@
|
||||
#ifndef LLVM_ANALYSIS_INTERVALPARTITION_H
|
||||
#define LLVM_ANALYSIS_INTERVALPARTITION_H
|
||||
|
||||
#include "llvm/Analysis/Interval.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class BasicBlock;
|
||||
class Interval;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// IntervalPartition - This class builds and holds an "interval partition" for
|
||||
@ -38,17 +41,17 @@ namespace llvm {
|
||||
// nodes following it.
|
||||
//
|
||||
class IntervalPartition : public FunctionPass {
|
||||
typedef std::map<BasicBlock*, Interval*> IntervalMapTy;
|
||||
using IntervalMapTy = std::map<BasicBlock *, Interval *>;
|
||||
IntervalMapTy IntervalMap;
|
||||
|
||||
typedef std::vector<Interval*> IntervalListTy;
|
||||
Interval *RootInterval;
|
||||
std::vector<Interval*> Intervals;
|
||||
using IntervalListTy = std::vector<Interval *>;
|
||||
Interval *RootInterval = nullptr;
|
||||
std::vector<Interval *> Intervals;
|
||||
|
||||
public:
|
||||
static char ID; // Pass identification, replacement for typeid
|
||||
|
||||
IntervalPartition() : FunctionPass(ID), RootInterval(nullptr) {
|
||||
IntervalPartition() : FunctionPass(ID) {
|
||||
initializeIntervalPartitionPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
@ -58,7 +61,6 @@ public:
|
||||
// IntervalPartition ctor - Build a reduced interval partition from an
|
||||
// existing interval graph. This takes an additional boolean parameter to
|
||||
// distinguish it from a copy constructor. Always pass in false for now.
|
||||
//
|
||||
IntervalPartition(IntervalPartition &I, bool);
|
||||
|
||||
// print - Show contents in human readable format...
|
||||
@ -95,17 +97,15 @@ private:
|
||||
// addIntervalToPartition - Add an interval to the internal list of intervals,
|
||||
// and then add mappings from all of the basic blocks in the interval to the
|
||||
// interval itself (in the IntervalMap).
|
||||
//
|
||||
void addIntervalToPartition(Interval *I);
|
||||
|
||||
// updatePredecessors - Interval generation only sets the successor fields of
|
||||
// the interval data structures. After interval generation is complete,
|
||||
// run through all of the intervals and propagate successor info as
|
||||
// predecessor info.
|
||||
//
|
||||
void updatePredecessors(Interval *Int);
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
#endif // LLVM_ANALYSIS_INTERVALPARTITION_H
|
||||
|
@ -13,17 +13,29 @@
|
||||
|
||||
#include "llvm/Analysis/AliasSetTracker.h"
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
#include "llvm/Analysis/MemoryLocation.h"
|
||||
#include "llvm/IR/CallSite.h"
|
||||
#include "llvm/IR/Constants.h"
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
#include "llvm/IR/InstIterator.h"
|
||||
#include "llvm/IR/Instruction.h"
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/IntrinsicInst.h"
|
||||
#include "llvm/IR/LLVMContext.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/Type.h"
|
||||
#include "llvm/IR/Value.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Support/AtomicOrdering.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
static cl::opt<unsigned>
|
||||
@ -106,7 +118,6 @@ void AliasSetTracker::removeAliasSet(AliasSet *AS) {
|
||||
TotalMayAliasSetSize -= AS->size();
|
||||
|
||||
AliasSets.erase(AS);
|
||||
|
||||
}
|
||||
|
||||
void AliasSet::removeFromTracker(AliasSetTracker &AST) {
|
||||
@ -580,7 +591,6 @@ AliasSet &AliasSetTracker::mergeAllAliasSets() {
|
||||
AliasSet &AliasSetTracker::addPointer(Value *P, uint64_t Size,
|
||||
const AAMDNodes &AAInfo,
|
||||
AliasSet::AccessLattice E) {
|
||||
|
||||
AliasSet &AS = getAliasSetForPointer(P, Size, AAInfo);
|
||||
AS.Access |= E;
|
||||
|
||||
@ -611,7 +621,6 @@ void AliasSet::print(raw_ostream &OS) const {
|
||||
if (Forward)
|
||||
OS << " forwarding to " << (void*)Forward;
|
||||
|
||||
|
||||
if (!empty()) {
|
||||
OS << "Pointers: ";
|
||||
for (iterator I = begin(), E = end(); I != E; ++I) {
|
||||
@ -671,10 +680,13 @@ AliasSetTracker::ASTCallbackVH::operator=(Value *V) {
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
namespace {
|
||||
|
||||
class AliasSetPrinter : public FunctionPass {
|
||||
AliasSetTracker *Tracker;
|
||||
|
||||
public:
|
||||
static char ID; // Pass identification, replacement for typeid
|
||||
|
||||
AliasSetPrinter() : FunctionPass(ID) {
|
||||
initializeAliasSetPrinterPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
@ -695,9 +707,11 @@ namespace {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
char AliasSetPrinter::ID = 0;
|
||||
|
||||
INITIALIZE_PASS_BEGIN(AliasSetPrinter, "print-alias-sets",
|
||||
"Alias Set Printer", false, true)
|
||||
INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
|
||||
|
@ -8,12 +8,20 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Analysis/CallGraph.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/IR/CallSite.h"
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/IntrinsicInst.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
#include "llvm/IR/Intrinsics.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -125,7 +133,6 @@ Function *CallGraph::removeFunctionFromModule(CallGraphNode *CGN) {
|
||||
/// This does not rescan the body of the function, so it is suitable when
|
||||
/// splicing the body of the old function to the new while also updating all
|
||||
/// callers from old to new.
|
||||
///
|
||||
void CallGraph::spliceFunction(const Function *From, const Function *To) {
|
||||
assert(FunctionMap.count(From) && "No CallGraphNode for function!");
|
||||
assert(!FunctionMap.count(To) &&
|
||||
@ -256,7 +263,7 @@ CallGraphWrapperPass::CallGraphWrapperPass() : ModulePass(ID) {
|
||||
initializeCallGraphWrapperPassPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
CallGraphWrapperPass::~CallGraphWrapperPass() {}
|
||||
CallGraphWrapperPass::~CallGraphWrapperPass() = default;
|
||||
|
||||
void CallGraphWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.setPreservesAll();
|
||||
@ -291,8 +298,10 @@ void CallGraphWrapperPass::dump() const { print(dbgs(), nullptr); }
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
struct CallGraphPrinterLegacyPass : public ModulePass {
|
||||
static char ID; // Pass ID, replacement for typeid
|
||||
|
||||
CallGraphPrinterLegacyPass() : ModulePass(ID) {
|
||||
initializeCallGraphPrinterLegacyPassPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
@ -301,12 +310,14 @@ struct CallGraphPrinterLegacyPass : public ModulePass {
|
||||
AU.setPreservesAll();
|
||||
AU.addRequiredTransitive<CallGraphWrapperPass>();
|
||||
}
|
||||
|
||||
bool runOnModule(Module &M) override {
|
||||
getAnalysis<CallGraphWrapperPass>().print(errs(), &M);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
char CallGraphPrinterLegacyPass::ID = 0;
|
||||
|
||||
|
@ -9,15 +9,23 @@
|
||||
|
||||
#include "llvm/Analysis/DominanceFrontier.h"
|
||||
#include "llvm/Analysis/DominanceFrontierImpl.h"
|
||||
#include "llvm/IR/Dominators.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
namespace llvm {
|
||||
|
||||
template class DominanceFrontierBase<BasicBlock, false>;
|
||||
template class DominanceFrontierBase<BasicBlock, true>;
|
||||
template class ForwardDominanceFrontierBase<BasicBlock>;
|
||||
}
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
char DominanceFrontierWrapperPass::ID = 0;
|
||||
|
||||
@ -27,7 +35,7 @@ INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
|
||||
INITIALIZE_PASS_END(DominanceFrontierWrapperPass, "domfrontier",
|
||||
"Dominance Frontier Construction", true, true)
|
||||
|
||||
DominanceFrontierWrapperPass::DominanceFrontierWrapperPass()
|
||||
DominanceFrontierWrapperPass::DominanceFrontierWrapperPass()
|
||||
: FunctionPass(ID), DF() {
|
||||
initializeDominanceFrontierWrapperPassPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "llvm/IR/BasicBlock.h"
|
||||
#include "llvm/IR/CFG.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
@ -25,7 +24,6 @@ using namespace llvm;
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// isLoop - Find out if there is a back edge in this interval...
|
||||
//
|
||||
bool Interval::isLoop() const {
|
||||
// There is a loop in this interval iff one of the predecessors of the header
|
||||
// node lives in the interval.
|
||||
@ -36,7 +34,6 @@ bool Interval::isLoop() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Interval::print(raw_ostream &OS) const {
|
||||
OS << "-------------------------------------------------------------\n"
|
||||
<< "Interval Contents:\n";
|
||||
|
@ -12,10 +12,17 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Analysis/IntervalPartition.h"
|
||||
#include "llvm/Analysis/Interval.h"
|
||||
#include "llvm/Analysis/IntervalIterator.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include <cassert>
|
||||
#include <utility>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
char IntervalPartition::ID = 0;
|
||||
|
||||
INITIALIZE_PASS(IntervalPartition, "intervals",
|
||||
"Interval Partition Construction", true, true)
|
||||
|
||||
@ -40,7 +47,6 @@ void IntervalPartition::print(raw_ostream &O, const Module*) const {
|
||||
// addIntervalToPartition - Add an interval to the internal list of intervals,
|
||||
// and then add mappings from all of the basic blocks in the interval to the
|
||||
// interval itself (in the IntervalMap).
|
||||
//
|
||||
void IntervalPartition::addIntervalToPartition(Interval *I) {
|
||||
Intervals.push_back(I);
|
||||
|
||||
@ -54,7 +60,6 @@ void IntervalPartition::addIntervalToPartition(Interval *I) {
|
||||
// the interval data structures. After interval generation is complete,
|
||||
// run through all of the intervals and propagate successor info as
|
||||
// predecessor info.
|
||||
//
|
||||
void IntervalPartition::updatePredecessors(Interval *Int) {
|
||||
BasicBlock *Header = Int->getHeaderNode();
|
||||
for (BasicBlock *Successor : Int->Successors)
|
||||
@ -63,7 +68,6 @@ void IntervalPartition::updatePredecessors(Interval *Int) {
|
||||
|
||||
// IntervalPartition ctor - Build the first level interval partition for the
|
||||
// specified function...
|
||||
//
|
||||
bool IntervalPartition::runOnFunction(Function &F) {
|
||||
// Pass false to intervals_begin because we take ownership of it's memory
|
||||
function_interval_iterator I = intervals_begin(&F, false);
|
||||
@ -84,11 +88,9 @@ bool IntervalPartition::runOnFunction(Function &F) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// IntervalPartition ctor - Build a reduced interval partition from an
|
||||
// existing interval graph. This takes an additional boolean parameter to
|
||||
// distinguish it from a copy constructor. Always pass in false for now.
|
||||
//
|
||||
IntervalPartition::IntervalPartition(IntervalPartition &IP, bool)
|
||||
: FunctionPass(ID) {
|
||||
assert(IP.getRootInterval() && "Cannot operate on empty IntervalPartitions!");
|
||||
@ -110,4 +112,3 @@ IntervalPartition::IntervalPartition(IntervalPartition &IP, bool)
|
||||
for (unsigned i = 0, e = Intervals.size(); i != e; ++i)
|
||||
updatePredecessors(Intervals[i]);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user