diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-06-21 13:59:01 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-06-21 13:59:01 +0000 |
commit | 3a0822f094b578157263e04114075ad7df81db41 (patch) | |
tree | bc48361fe2cd1ca5f93ac01b38b183774468fc79 /include/llvm/Analysis | |
parent | 85d8b2bbe386bcfe669575d05b61482d7be07e5d (diff) |
Diffstat (limited to 'include/llvm/Analysis')
46 files changed, 162 insertions, 136 deletions
diff --git a/include/llvm/Analysis/AliasAnalysis.h b/include/llvm/Analysis/AliasAnalysis.h index de18e585f11d..7f037fb5e813 100644 --- a/include/llvm/Analysis/AliasAnalysis.h +++ b/include/llvm/Analysis/AliasAnalysis.h @@ -16,11 +16,12 @@ // which automatically provides functionality for the entire suite of client // APIs. // -// This API identifies memory regions with the Location class. The pointer +// This API identifies memory regions with the MemoryLocation class. The pointer // component specifies the base memory address of the region. The Size specifies -// the maximum size (in address units) of the memory region, or UnknownSize if -// the size is not known. The TBAA tag identifies the "type" of the memory -// reference; see the TypeBasedAliasAnalysis class for details. +// the maximum size (in address units) of the memory region, or +// MemoryLocation::UnknownSize if the size is not known. The TBAA tag +// identifies the "type" of the memory reference; see the +// TypeBasedAliasAnalysis class for details. // // Some non-obvious details include: // - Pointers that point to two completely different objects in memory never @@ -80,11 +81,6 @@ public: AliasAnalysis() : DL(nullptr), TLI(nullptr), AA(nullptr) {} virtual ~AliasAnalysis(); // We want to be subclassed - /// UnknownSize - This is a special value which can be used with the - /// size arguments in alias queries to indicate that the caller does not - /// know the sizes of the potential memory references. - static uint64_t const UnknownSize = MemoryLocation::UnknownSize; - /// getTargetLibraryInfo - Return a pointer to the current TargetLibraryInfo /// object, or null if no TargetLibraryInfo object is available. /// @@ -99,10 +95,6 @@ public: /// Alias Queries... /// - /// Legacy typedef for the AA location object. New code should use \c - /// MemoryLocation directly. - typedef MemoryLocation Location; - /// Alias analysis result - Either we know for sure that it does not alias, we /// know for sure it must alias, or we don't know anything: The two pointers /// _might_ alias. This enum is designed so you can do things like: @@ -123,38 +115,40 @@ public: /// Returns an AliasResult indicating whether the two pointers are aliased to /// each other. This is the interface that must be implemented by specific /// alias analysis implementations. - virtual AliasResult alias(const Location &LocA, const Location &LocB); + virtual AliasResult alias(const MemoryLocation &LocA, + const MemoryLocation &LocB); /// alias - A convenience wrapper. AliasResult alias(const Value *V1, uint64_t V1Size, const Value *V2, uint64_t V2Size) { - return alias(Location(V1, V1Size), Location(V2, V2Size)); + return alias(MemoryLocation(V1, V1Size), MemoryLocation(V2, V2Size)); } /// alias - A convenience wrapper. AliasResult alias(const Value *V1, const Value *V2) { - return alias(V1, UnknownSize, V2, UnknownSize); + return alias(V1, MemoryLocation::UnknownSize, V2, + MemoryLocation::UnknownSize); } /// isNoAlias - A trivial helper function to check to see if the specified /// pointers are no-alias. - bool isNoAlias(const Location &LocA, const Location &LocB) { + bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) { return alias(LocA, LocB) == NoAlias; } /// isNoAlias - A convenience wrapper. bool isNoAlias(const Value *V1, uint64_t V1Size, const Value *V2, uint64_t V2Size) { - return isNoAlias(Location(V1, V1Size), Location(V2, V2Size)); + return isNoAlias(MemoryLocation(V1, V1Size), MemoryLocation(V2, V2Size)); } /// isNoAlias - A convenience wrapper. bool isNoAlias(const Value *V1, const Value *V2) { - return isNoAlias(Location(V1), Location(V2)); + return isNoAlias(MemoryLocation(V1), MemoryLocation(V2)); } /// isMustAlias - A convenience wrapper. - bool isMustAlias(const Location &LocA, const Location &LocB) { + bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB) { return alias(LocA, LocB) == MustAlias; } @@ -167,12 +161,12 @@ public: /// known to be constant, return true. If OrLocal is true and the /// specified memory location is known to be "local" (derived from /// an alloca), return true. Otherwise return false. - virtual bool pointsToConstantMemory(const Location &Loc, + virtual bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal = false); /// pointsToConstantMemory - A convenient wrapper. bool pointsToConstantMemory(const Value *P, bool OrLocal = false) { - return pointsToConstantMemory(Location(P), OrLocal); + return pointsToConstantMemory(MemoryLocation(P), OrLocal); } //===--------------------------------------------------------------------===// @@ -228,13 +222,12 @@ public: UnknownModRefBehavior = Anywhere | ModRef }; - /// Get the location associated with a pointer argument of a callsite. - /// The mask bits are set to indicate the allowed aliasing ModRef kinds. - /// Note that these mask bits do not necessarily account for the overall - /// behavior of the function, but rather only provide additional - /// per-argument information. - virtual Location getArgLocation(ImmutableCallSite CS, unsigned ArgIdx, - ModRefResult &Mask); + /// Get the ModRef info associated with a pointer argument of a callsite. The + /// result's bits are set to indicate the allowed aliasing ModRef kinds. Note + /// that these bits do not necessarily account for the overall behavior of + /// the function, but rather only provide additional per-argument + /// information. + virtual ModRefResult getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx); /// getModRefBehavior - Return the behavior when calling the given call site. virtual ModRefBehavior getModRefBehavior(ImmutableCallSite CS); @@ -324,14 +317,13 @@ public: return NoModRef; } - return getModRefInfo(I, Location()); + return getModRefInfo(I, MemoryLocation()); } /// getModRefInfo - Return information about whether or not an instruction may /// read or write the specified memory location. An instruction /// that doesn't read or write memory may be trivially LICM'd for example. - ModRefResult getModRefInfo(const Instruction *I, - const Location &Loc) { + ModRefResult getModRefInfo(const Instruction *I, const MemoryLocation &Loc) { switch (I->getOpcode()) { case Instruction::VAArg: return getModRefInfo((const VAArgInst*)I, Loc); case Instruction::Load: return getModRefInfo((const LoadInst*)I, Loc); @@ -350,65 +342,64 @@ public: /// getModRefInfo - A convenience wrapper. ModRefResult getModRefInfo(const Instruction *I, const Value *P, uint64_t Size) { - return getModRefInfo(I, Location(P, Size)); + return getModRefInfo(I, MemoryLocation(P, Size)); } /// getModRefInfo (for call sites) - Return information about whether /// a particular call site modifies or reads the specified memory location. virtual ModRefResult getModRefInfo(ImmutableCallSite CS, - const Location &Loc); + const MemoryLocation &Loc); /// getModRefInfo (for call sites) - A convenience wrapper. ModRefResult getModRefInfo(ImmutableCallSite CS, const Value *P, uint64_t Size) { - return getModRefInfo(CS, Location(P, Size)); + return getModRefInfo(CS, MemoryLocation(P, Size)); } /// getModRefInfo (for calls) - Return information about whether /// a particular call modifies or reads the specified memory location. - ModRefResult getModRefInfo(const CallInst *C, const Location &Loc) { + ModRefResult getModRefInfo(const CallInst *C, const MemoryLocation &Loc) { return getModRefInfo(ImmutableCallSite(C), Loc); } /// getModRefInfo (for calls) - A convenience wrapper. ModRefResult getModRefInfo(const CallInst *C, const Value *P, uint64_t Size) { - return getModRefInfo(C, Location(P, Size)); + return getModRefInfo(C, MemoryLocation(P, Size)); } /// getModRefInfo (for invokes) - Return information about whether /// a particular invoke modifies or reads the specified memory location. - ModRefResult getModRefInfo(const InvokeInst *I, - const Location &Loc) { + ModRefResult getModRefInfo(const InvokeInst *I, const MemoryLocation &Loc) { return getModRefInfo(ImmutableCallSite(I), Loc); } /// getModRefInfo (for invokes) - A convenience wrapper. ModRefResult getModRefInfo(const InvokeInst *I, const Value *P, uint64_t Size) { - return getModRefInfo(I, Location(P, Size)); + return getModRefInfo(I, MemoryLocation(P, Size)); } /// getModRefInfo (for loads) - Return information about whether /// a particular load modifies or reads the specified memory location. - ModRefResult getModRefInfo(const LoadInst *L, const Location &Loc); + ModRefResult getModRefInfo(const LoadInst *L, const MemoryLocation &Loc); /// getModRefInfo (for loads) - A convenience wrapper. ModRefResult getModRefInfo(const LoadInst *L, const Value *P, uint64_t Size) { - return getModRefInfo(L, Location(P, Size)); + return getModRefInfo(L, MemoryLocation(P, Size)); } /// getModRefInfo (for stores) - Return information about whether /// a particular store modifies or reads the specified memory location. - ModRefResult getModRefInfo(const StoreInst *S, const Location &Loc); + ModRefResult getModRefInfo(const StoreInst *S, const MemoryLocation &Loc); /// getModRefInfo (for stores) - A convenience wrapper. ModRefResult getModRefInfo(const StoreInst *S, const Value *P, uint64_t Size){ - return getModRefInfo(S, Location(P, Size)); + return getModRefInfo(S, MemoryLocation(P, Size)); } /// getModRefInfo (for fences) - Return information about whether /// a particular store modifies or reads the specified memory location. - ModRefResult getModRefInfo(const FenceInst *S, const Location &Loc) { + ModRefResult getModRefInfo(const FenceInst *S, const MemoryLocation &Loc) { // Conservatively correct. (We could possibly be a bit smarter if // Loc is a alloca that doesn't escape.) return ModRef; @@ -416,36 +407,38 @@ public: /// getModRefInfo (for fences) - A convenience wrapper. ModRefResult getModRefInfo(const FenceInst *S, const Value *P, uint64_t Size){ - return getModRefInfo(S, Location(P, Size)); + return getModRefInfo(S, MemoryLocation(P, Size)); } /// getModRefInfo (for cmpxchges) - Return information about whether /// a particular cmpxchg modifies or reads the specified memory location. - ModRefResult getModRefInfo(const AtomicCmpXchgInst *CX, const Location &Loc); + ModRefResult getModRefInfo(const AtomicCmpXchgInst *CX, + const MemoryLocation &Loc); /// getModRefInfo (for cmpxchges) - A convenience wrapper. ModRefResult getModRefInfo(const AtomicCmpXchgInst *CX, const Value *P, unsigned Size) { - return getModRefInfo(CX, Location(P, Size)); + return getModRefInfo(CX, MemoryLocation(P, Size)); } /// getModRefInfo (for atomicrmws) - Return information about whether /// a particular atomicrmw modifies or reads the specified memory location. - ModRefResult getModRefInfo(const AtomicRMWInst *RMW, const Location &Loc); + ModRefResult getModRefInfo(const AtomicRMWInst *RMW, + const MemoryLocation &Loc); /// getModRefInfo (for atomicrmws) - A convenience wrapper. ModRefResult getModRefInfo(const AtomicRMWInst *RMW, const Value *P, unsigned Size) { - return getModRefInfo(RMW, Location(P, Size)); + return getModRefInfo(RMW, MemoryLocation(P, Size)); } /// getModRefInfo (for va_args) - Return information about whether /// a particular va_arg modifies or reads the specified memory location. - ModRefResult getModRefInfo(const VAArgInst* I, const Location &Loc); + ModRefResult getModRefInfo(const VAArgInst *I, const MemoryLocation &Loc); /// getModRefInfo (for va_args) - A convenience wrapper. ModRefResult getModRefInfo(const VAArgInst* I, const Value* P, uint64_t Size){ - return getModRefInfo(I, Location(P, Size)); + return getModRefInfo(I, MemoryLocation(P, Size)); } /// getModRefInfo - Return information about whether a call and an instruction /// may refer to the same memory locations. @@ -462,13 +455,13 @@ public: /// callCapturesBefore - Return information about whether a particular call /// site modifies or reads the specified memory location. ModRefResult callCapturesBefore(const Instruction *I, - const AliasAnalysis::Location &MemLoc, + const MemoryLocation &MemLoc, DominatorTree *DT); /// callCapturesBefore - A convenience wrapper. ModRefResult callCapturesBefore(const Instruction *I, const Value *P, uint64_t Size, DominatorTree *DT) { - return callCapturesBefore(I, Location(P, Size), DT); + return callCapturesBefore(I, MemoryLocation(P, Size), DT); } //===--------------------------------------------------------------------===// @@ -477,11 +470,11 @@ public: /// canBasicBlockModify - Return true if it is possible for execution of the /// specified basic block to modify the location Loc. - bool canBasicBlockModify(const BasicBlock &BB, const Location &Loc); + bool canBasicBlockModify(const BasicBlock &BB, const MemoryLocation &Loc); /// canBasicBlockModify - A convenience wrapper. bool canBasicBlockModify(const BasicBlock &BB, const Value *P, uint64_t Size){ - return canBasicBlockModify(BB, Location(P, Size)); + return canBasicBlockModify(BB, MemoryLocation(P, Size)); } /// canInstructionRangeModRef - Return true if it is possible for the @@ -489,15 +482,15 @@ public: /// mode) the location Loc. The instructions to consider are all /// of the instructions in the range of [I1,I2] INCLUSIVE. /// I1 and I2 must be in the same basic block. - bool canInstructionRangeModRef(const Instruction &I1, - const Instruction &I2, const Location &Loc, - const ModRefResult Mode); + bool canInstructionRangeModRef(const Instruction &I1, const Instruction &I2, + const MemoryLocation &Loc, + const ModRefResult Mode); /// canInstructionRangeModRef - A convenience wrapper. bool canInstructionRangeModRef(const Instruction &I1, const Instruction &I2, const Value *Ptr, uint64_t Size, const ModRefResult Mode) { - return canInstructionRangeModRef(I1, I2, Location(Ptr, Size), Mode); + return canInstructionRangeModRef(I1, I2, MemoryLocation(Ptr, Size), Mode); } //===--------------------------------------------------------------------===// @@ -565,6 +558,6 @@ bool isIdentifiedObject(const Value *V); /// IdentifiedObjects. bool isIdentifiedFunctionLocal(const Value *V); -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/AliasSetTracker.h b/include/llvm/Analysis/AliasSetTracker.h index 18f95b401e6a..ba2eae903da6 100644 --- a/include/llvm/Analysis/AliasSetTracker.h +++ b/include/llvm/Analysis/AliasSetTracker.h @@ -437,6 +437,6 @@ inline raw_ostream& operator<<(raw_ostream &OS, const AliasSetTracker &AST) { return OS; } -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/BlockFrequencyInfo.h b/include/llvm/Analysis/BlockFrequencyInfo.h index f27c32df9283..382c080a2c03 100644 --- a/include/llvm/Analysis/BlockFrequencyInfo.h +++ b/include/llvm/Analysis/BlockFrequencyInfo.h @@ -63,6 +63,6 @@ public: }; -} +} // namespace llvm #endif diff --git a/include/llvm/Analysis/BlockFrequencyInfoImpl.h b/include/llvm/Analysis/BlockFrequencyInfoImpl.h index 85a299b6dddf..bf24f66cbca9 100644 --- a/include/llvm/Analysis/BlockFrequencyInfoImpl.h +++ b/include/llvm/Analysis/BlockFrequencyInfoImpl.h @@ -196,23 +196,26 @@ public: struct LoopData { typedef SmallVector<std::pair<BlockNode, BlockMass>, 4> ExitMap; typedef SmallVector<BlockNode, 4> NodeList; - LoopData *Parent; ///< The parent loop. - bool IsPackaged; ///< Whether this has been packaged. - uint32_t NumHeaders; ///< Number of headers. - ExitMap Exits; ///< Successor edges (and weights). - NodeList Nodes; ///< Header and the members of the loop. - BlockMass BackedgeMass; ///< Mass returned to loop header. + typedef SmallVector<BlockMass, 1> HeaderMassList; + LoopData *Parent; ///< The parent loop. + bool IsPackaged; ///< Whether this has been packaged. + uint32_t NumHeaders; ///< Number of headers. + ExitMap Exits; ///< Successor edges (and weights). + NodeList Nodes; ///< Header and the members of the loop. + HeaderMassList BackedgeMass; ///< Mass returned to each loop header. BlockMass Mass; Scaled64 Scale; LoopData(LoopData *Parent, const BlockNode &Header) - : Parent(Parent), IsPackaged(false), NumHeaders(1), Nodes(1, Header) {} + : Parent(Parent), IsPackaged(false), NumHeaders(1), Nodes(1, Header), + BackedgeMass(1) {} template <class It1, class It2> LoopData(LoopData *Parent, It1 FirstHeader, It1 LastHeader, It2 FirstOther, It2 LastOther) : Parent(Parent), IsPackaged(false), Nodes(FirstHeader, LastHeader) { NumHeaders = Nodes.size(); Nodes.insert(Nodes.end(), FirstOther, LastOther); + BackedgeMass.resize(NumHeaders); } bool isHeader(const BlockNode &Node) const { if (isIrreducible()) @@ -223,6 +226,14 @@ public: BlockNode getHeader() const { return Nodes[0]; } bool isIrreducible() const { return NumHeaders > 1; } + HeaderMassList::difference_type getHeaderIndex(const BlockNode &B) { + assert(isHeader(B) && "this is only valid on loop header blocks"); + if (isIrreducible()) + return std::lower_bound(Nodes.begin(), Nodes.begin() + NumHeaders, B) - + Nodes.begin(); + return 0; + } + NodeList::const_iterator members_begin() const { return Nodes.begin() + NumHeaders; } @@ -431,6 +442,16 @@ public: /// \brief Compute the loop scale for a loop. void computeLoopScale(LoopData &Loop); + /// Adjust the mass of all headers in an irreducible loop. + /// + /// Initially, irreducible loops are assumed to distribute their mass + /// equally among its headers. This can lead to wrong frequency estimates + /// since some headers may be executed more frequently than others. + /// + /// This adjusts header mass distribution so it matches the weights of + /// the backedges going into each of the loop headers. + void adjustLoopHeaderMass(LoopData &Loop); + /// \brief Package up a loop. void packageLoop(LoopData &Loop); @@ -607,7 +628,7 @@ void IrreducibleGraph::addEdges(const BlockNode &Node, else addBlockEdges(*this, Irr, OuterLoop); } -} +} // namespace bfi_detail /// \brief Shared implementation for block frequency analysis. /// @@ -695,6 +716,17 @@ void IrreducibleGraph::addEdges(const BlockNode &Node, /// - Distribute the mass accordingly, dithering to minimize mass loss, /// as described in \a distributeMass(). /// +/// In the case of irreducible loops, instead of a single loop header, +/// there will be several. The computation of backedge masses is similar +/// but instead of having a single backedge mass, there will be one +/// backedge per loop header. In these cases, each backedge will carry +/// a mass proportional to the edge weights along the corresponding +/// path. +/// +/// At the end of propagation, the full mass assigned to the loop will be +/// distributed among the loop headers proportionally according to the +/// mass flowing through their backedges. +/// /// Finally, calculate the loop scale from the accumulated backedge mass. /// /// 3. Distribute mass in the function (\a computeMassInFunction()). @@ -735,11 +767,6 @@ void IrreducibleGraph::addEdges(const BlockNode &Node, /// as sub-loops, rather than arbitrarily shoving the problematic /// blocks into the headers of the main irreducible SCC. /// -/// - Backedge frequencies are assumed to be evenly split between the -/// headers of a given irreducible SCC. Instead, we could track the -/// backedge mass separately for each header, and adjust their relative -/// frequencies. -/// /// - Entry frequencies are assumed to be evenly split between the /// headers of a given irreducible SCC, which is the only option if we /// need to compute mass in the SCC before its parent loop. Instead, @@ -846,7 +873,7 @@ template <class BT> class BlockFrequencyInfoImpl : BlockFrequencyInfoImplBase { /// /// \pre \a computeMassInLoop() has been called for each subloop of \c /// OuterLoop. - /// \pre \c Insert points at the the last loop successfully processed by \a + /// \pre \c Insert points at the last loop successfully processed by \a /// computeMassInLoop(). /// \pre \c OuterLoop has irreducible SCCs. void computeIrreducibleMass(LoopData *OuterLoop, @@ -1042,6 +1069,8 @@ bool BlockFrequencyInfoImpl<BT>::computeMassInLoop(LoopData &Loop) { for (const BlockNode &M : Loop.Nodes) if (!propagateMassToSuccessors(&Loop, M)) llvm_unreachable("unhandled irreducible control flow"); + + adjustLoopHeaderMass(Loop); } else { Working[Loop.getHeader().Index].getMass() = BlockMass::getFull(); if (!propagateMassToSuccessors(&Loop, Loop.getHeader())) @@ -1104,7 +1133,7 @@ template <class BT> struct BlockEdgesAdder { G.addEdge(Irr, BFI.getNode(*I), OuterLoop); } }; -} +} // namespace bfi_detail template <class BT> void BlockFrequencyInfoImpl<BT>::computeIrreducibleMass( LoopData *OuterLoop, std::list<LoopData>::iterator Insert) { diff --git a/include/llvm/Analysis/BranchProbabilityInfo.h b/include/llvm/Analysis/BranchProbabilityInfo.h index 9d867567ba29..f2ca3e0d07cf 100644 --- a/include/llvm/Analysis/BranchProbabilityInfo.h +++ b/include/llvm/Analysis/BranchProbabilityInfo.h @@ -158,6 +158,6 @@ private: bool calcInvokeHeuristics(BasicBlock *BB); }; -} +} // namespace llvm #endif diff --git a/include/llvm/Analysis/CFG.h b/include/llvm/Analysis/CFG.h index 7f92eda8cb20..f837cb4f59cb 100644 --- a/include/llvm/Analysis/CFG.h +++ b/include/llvm/Analysis/CFG.h @@ -78,6 +78,6 @@ bool isPotentiallyReachable(const BasicBlock *From, const BasicBlock *To, const DominatorTree *DT = nullptr, const LoopInfo *LI = nullptr); -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/CFGPrinter.h b/include/llvm/Analysis/CFGPrinter.h index 035764837e6f..0cc4e5d33975 100644 --- a/include/llvm/Analysis/CFGPrinter.h +++ b/include/llvm/Analysis/CFGPrinter.h @@ -119,7 +119,7 @@ struct DOTGraphTraits<const Function*> : public DefaultDOTGraphTraits { return ""; } }; -} // End llvm namespace +} // namespace llvm namespace llvm { class FunctionPass; diff --git a/include/llvm/Analysis/CGSCCPassManager.h b/include/llvm/Analysis/CGSCCPassManager.h index 6a406cd24402..42f0e651ec94 100644 --- a/include/llvm/Analysis/CGSCCPassManager.h +++ b/include/llvm/Analysis/CGSCCPassManager.h @@ -485,6 +485,6 @@ CGSCCToFunctionPassAdaptor<FunctionPassT> createCGSCCToFunctionPassAdaptor(FunctionPassT Pass) { return CGSCCToFunctionPassAdaptor<FunctionPassT>(std::move(Pass)); } -} +} // namespace llvm #endif diff --git a/include/llvm/Analysis/CallGraph.h b/include/llvm/Analysis/CallGraph.h index 5b64d857bf71..ed52e864a059 100644 --- a/include/llvm/Analysis/CallGraph.h +++ b/include/llvm/Analysis/CallGraph.h @@ -56,6 +56,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/IR/CallSite.h" #include "llvm/IR/Function.h" +#include "llvm/IR/Intrinsics.h" #include "llvm/IR/ValueHandle.h" #include "llvm/Pass.h" #include <map> @@ -229,7 +230,8 @@ public: /// \brief Adds a function to the list of functions called by this one. void addCalledFunction(CallSite CS, CallGraphNode *M) { assert(!CS.getInstruction() || !CS.getCalledFunction() || - !CS.getCalledFunction()->isIntrinsic()); + !CS.getCalledFunction()->isIntrinsic() || + !Intrinsic::isLeaf(CS.getCalledFunction()->getIntrinsicID())); CalledFunctions.emplace_back(CS.getInstruction(), M); M->AddRef(); } @@ -479,6 +481,6 @@ struct GraphTraits<const CallGraph *> : public GraphTraits< static const CallGraphNode &CGdereference(PairTy P) { return *P.second; } }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/CallGraphSCCPass.h b/include/llvm/Analysis/CallGraphSCCPass.h index 667e1715775f..94fa5bd7fb2a 100644 --- a/include/llvm/Analysis/CallGraphSCCPass.h +++ b/include/llvm/Analysis/CallGraphSCCPass.h @@ -102,6 +102,6 @@ public: iterator end() const { return Nodes.end(); } }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/CodeMetrics.h b/include/llvm/Analysis/CodeMetrics.h index 2f5969129e02..6ab83aefe81b 100644 --- a/include/llvm/Analysis/CodeMetrics.h +++ b/include/llvm/Analysis/CodeMetrics.h @@ -102,6 +102,6 @@ struct CodeMetrics { SmallPtrSetImpl<const Value *> &EphValues); }; -} +} // namespace llvm #endif diff --git a/include/llvm/Analysis/ConstantFolding.h b/include/llvm/Analysis/ConstantFolding.h index 541a2109af6c..a0d5eaba9c7b 100644 --- a/include/llvm/Analysis/ConstantFolding.h +++ b/include/llvm/Analysis/ConstantFolding.h @@ -97,6 +97,6 @@ bool canConstantFoldCallTo(const Function *F); /// with the specified arguments, returning null if unsuccessful. Constant *ConstantFoldCall(Function *F, ArrayRef<Constant *> Operands, const TargetLibraryInfo *TLI = nullptr); -} +} // namespace llvm #endif diff --git a/include/llvm/Analysis/DomPrinter.h b/include/llvm/Analysis/DomPrinter.h index 0ed28994995a..1402d7749d79 100644 --- a/include/llvm/Analysis/DomPrinter.h +++ b/include/llvm/Analysis/DomPrinter.h @@ -25,6 +25,6 @@ namespace llvm { FunctionPass *createPostDomOnlyPrinterPass(); FunctionPass *createPostDomViewerPass(); FunctionPass *createPostDomOnlyViewerPass(); -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/DominanceFrontier.h b/include/llvm/Analysis/DominanceFrontier.h index 996700efdb60..0cdd73e01630 100644 --- a/include/llvm/Analysis/DominanceFrontier.h +++ b/include/llvm/Analysis/DominanceFrontier.h @@ -205,6 +205,6 @@ public: EXTERN_TEMPLATE_INSTANTIATION(class DominanceFrontierBase<BasicBlock>); EXTERN_TEMPLATE_INSTANTIATION(class ForwardDominanceFrontierBase<BasicBlock>); -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/DominanceFrontierImpl.h b/include/llvm/Analysis/DominanceFrontierImpl.h index 629ae3809045..4904f93c17ac 100644 --- a/include/llvm/Analysis/DominanceFrontierImpl.h +++ b/include/llvm/Analysis/DominanceFrontierImpl.h @@ -221,6 +221,6 @@ ForwardDominanceFrontierBase<BlockT>::calculate(const DomTreeT &DT, return *Result; } -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/IVUsers.h b/include/llvm/Analysis/IVUsers.h index ae9c1f5bd9ac..2ad0ae74eb10 100644 --- a/include/llvm/Analysis/IVUsers.h +++ b/include/llvm/Analysis/IVUsers.h @@ -178,6 +178,6 @@ protected: Pass *createIVUsersPass(); -} +} // namespace llvm #endif diff --git a/include/llvm/Analysis/InlineCost.h b/include/llvm/Analysis/InlineCost.h index 79ed74d82411..57da1325ec35 100644 --- a/include/llvm/Analysis/InlineCost.h +++ b/include/llvm/Analysis/InlineCost.h @@ -36,7 +36,7 @@ namespace InlineConstants { /// Do not inline functions which allocate this many bytes on the stack /// when the caller is recursive. const unsigned TotalAllocaSizeRecursiveCaller = 1024; -} +} // namespace InlineConstants /// \brief Represents the cost of inlining a function. /// @@ -138,6 +138,6 @@ public: bool isInlineViable(Function &Callee); }; -} +} // namespace llvm #endif diff --git a/include/llvm/Analysis/Interval.h b/include/llvm/Analysis/Interval.h index 01eba3f16c01..cbdb0c033499 100644 --- a/include/llvm/Analysis/Interval.h +++ b/include/llvm/Analysis/Interval.h @@ -145,6 +145,6 @@ template <> struct GraphTraits<Inverse<Interval*> > { } }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/IntervalIterator.h b/include/llvm/Analysis/IntervalIterator.h index 655ce2dab413..5ec50d46a9e7 100644 --- a/include/llvm/Analysis/IntervalIterator.h +++ b/include/llvm/Analysis/IntervalIterator.h @@ -263,6 +263,6 @@ inline interval_part_interval_iterator intervals_end(IntervalPartition &IP) { return interval_part_interval_iterator(); } -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/IntervalPartition.h b/include/llvm/Analysis/IntervalPartition.h index 274be2bdcfa9..2176d0c509f1 100644 --- a/include/llvm/Analysis/IntervalPartition.h +++ b/include/llvm/Analysis/IntervalPartition.h @@ -106,6 +106,6 @@ private: void updatePredecessors(Interval *Int); }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/IteratedDominanceFrontier.h b/include/llvm/Analysis/IteratedDominanceFrontier.h index 5a339f10f50f..eea0d81a8889 100644 --- a/include/llvm/Analysis/IteratedDominanceFrontier.h +++ b/include/llvm/Analysis/IteratedDominanceFrontier.h @@ -92,5 +92,5 @@ private: const SmallPtrSetImpl<BasicBlock *> *DefBlocks; SmallVector<BasicBlock *, 32> PHIBlocks; }; -} +} // namespace llvm #endif diff --git a/include/llvm/Analysis/JumpInstrTableInfo.h b/include/llvm/Analysis/JumpInstrTableInfo.h index b6dad478cdf2..ea331a4f516a 100644 --- a/include/llvm/Analysis/JumpInstrTableInfo.h +++ b/include/llvm/Analysis/JumpInstrTableInfo.h @@ -66,6 +66,6 @@ private: /// bound specifies the maximum number of bytes needed to represent an /// unconditional jump or a trap instruction in the back end currently in use. ModulePass *createJumpInstrTableInfoPass(unsigned Bound); -} +} // namespace llvm #endif /* LLVM_ANALYSIS_JUMPINSTRTABLEINFO_H */ diff --git a/include/llvm/Analysis/LazyCallGraph.h b/include/llvm/Analysis/LazyCallGraph.h index b0b9068de34b..af4861ff35bf 100644 --- a/include/llvm/Analysis/LazyCallGraph.h +++ b/include/llvm/Analysis/LazyCallGraph.h @@ -569,6 +569,6 @@ public: static StringRef name() { return "LazyCallGraphPrinterPass"; } }; -} +} // namespace llvm #endif diff --git a/include/llvm/Analysis/LibCallAliasAnalysis.h b/include/llvm/Analysis/LibCallAliasAnalysis.h index df95e0e6fdc2..a4b7e5d871fe 100644 --- a/include/llvm/Analysis/LibCallAliasAnalysis.h +++ b/include/llvm/Analysis/LibCallAliasAnalysis.h @@ -39,8 +39,8 @@ namespace llvm { ~LibCallAliasAnalysis() override; ModRefResult getModRefInfo(ImmutableCallSite CS, - const Location &Loc) override; - + const MemoryLocation &Loc) override; + ModRefResult getModRefInfo(ImmutableCallSite CS1, ImmutableCallSite CS2) override { // TODO: Could compare two direct calls against each other if we cared to. @@ -64,8 +64,8 @@ namespace llvm { private: ModRefResult AnalyzeLibCallDetails(const LibCallFunctionInfo *FI, ImmutableCallSite CS, - const Location &Loc); + const MemoryLocation &Loc); }; -} // End of llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/LibCallSemantics.h b/include/llvm/Analysis/LibCallSemantics.h index 34831b2849dd..170e2a49a8ea 100644 --- a/include/llvm/Analysis/LibCallSemantics.h +++ b/include/llvm/Analysis/LibCallSemantics.h @@ -48,8 +48,7 @@ class InvokeInst; enum LocResult { Yes, No, Unknown }; - LocResult (*isLocation)(ImmutableCallSite CS, - const AliasAnalysis::Location &Loc); + LocResult (*isLocation)(ImmutableCallSite CS, const MemoryLocation &Loc); }; /// LibCallFunctionInfo - Each record in the array of FunctionInfo structs @@ -207,7 +206,7 @@ class InvokeInst; llvm_unreachable("invalid enum"); } - bool canSimplifyInvokeNoUnwind(const InvokeInst *II); + bool canSimplifyInvokeNoUnwind(const Function *F); } // end namespace llvm diff --git a/include/llvm/Analysis/Lint.h b/include/llvm/Analysis/Lint.h index 7c88b137ec3b..79cd82ff1337 100644 --- a/include/llvm/Analysis/Lint.h +++ b/include/llvm/Analysis/Lint.h @@ -44,6 +44,6 @@ void lintFunction( const Function &F ///< The function to be checked ); -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/Loads.h b/include/llvm/Analysis/Loads.h index 42667d2af14a..c8a6e4a0e1d7 100644 --- a/include/llvm/Analysis/Loads.h +++ b/include/llvm/Analysis/Loads.h @@ -52,6 +52,6 @@ Value *FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB, AliasAnalysis *AA = nullptr, AAMDNodes *AATags = nullptr); -} +} // namespace llvm #endif diff --git a/include/llvm/Analysis/LoopAccessAnalysis.h b/include/llvm/Analysis/LoopAccessAnalysis.h index 7b635a8b4960..0f3c73147e11 100644 --- a/include/llvm/Analysis/LoopAccessAnalysis.h +++ b/include/llvm/Analysis/LoopAccessAnalysis.h @@ -555,6 +555,6 @@ private: DominatorTree *DT; LoopInfo *LI; }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index bbcde8d9721a..7bfebab46e20 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -763,6 +763,6 @@ public: void getAnalysisUsage(AnalysisUsage &AU) const override; }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/LoopInfoImpl.h b/include/llvm/Analysis/LoopInfoImpl.h index f5cc856f6247..b8f80df34bf9 100644 --- a/include/llvm/Analysis/LoopInfoImpl.h +++ b/include/llvm/Analysis/LoopInfoImpl.h @@ -535,6 +535,6 @@ void LoopInfoBase<BlockT, LoopT>::verify() const { #endif } -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/LoopPass.h b/include/llvm/Analysis/LoopPass.h index 8650000fcfb6..57ad79319756 100644 --- a/include/llvm/Analysis/LoopPass.h +++ b/include/llvm/Analysis/LoopPass.h @@ -169,6 +169,6 @@ private: Loop *CurrentLoop; }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/MemoryBuiltins.h b/include/llvm/Analysis/MemoryBuiltins.h index 805a43dfb070..557d6fcc0cb9 100644 --- a/include/llvm/Analysis/MemoryBuiltins.h +++ b/include/llvm/Analysis/MemoryBuiltins.h @@ -262,6 +262,6 @@ public: SizeOffsetEvalType visitInstruction(Instruction &I); }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/MemoryDependenceAnalysis.h b/include/llvm/Analysis/MemoryDependenceAnalysis.h index cf51dd62388f..9c50ae08f986 100644 --- a/include/llvm/Analysis/MemoryDependenceAnalysis.h +++ b/include/llvm/Analysis/MemoryDependenceAnalysis.h @@ -287,7 +287,7 @@ namespace llvm { /// conflicting tags. AAMDNodes AATags; - NonLocalPointerInfo() : Size(AliasAnalysis::UnknownSize) {} + NonLocalPointerInfo() : Size(MemoryLocation::UnknownSize) {} }; /// CachedNonLocalPointerInfo - This map stores the cached results of doing @@ -403,13 +403,12 @@ namespace llvm { /// /// Note that this is an uncached query, and thus may be inefficient. /// - MemDepResult getPointerDependencyFrom(const AliasAnalysis::Location &Loc, + MemDepResult getPointerDependencyFrom(const MemoryLocation &Loc, bool isLoad, BasicBlock::iterator ScanIt, BasicBlock *BB, Instruction *QueryInst = nullptr); - /// getLoadLoadClobberFullWidthSize - This is a little bit of analysis that /// looks at a memory location for a load (specified by MemLocBase, Offs, /// and Size) and compares it against a load. If the specified load could @@ -428,15 +427,14 @@ namespace llvm { BasicBlock *BB); bool getNonLocalPointerDepFromBB(Instruction *QueryInst, const PHITransAddr &Pointer, - const AliasAnalysis::Location &Loc, - bool isLoad, BasicBlock *BB, + const MemoryLocation &Loc, bool isLoad, + BasicBlock *BB, SmallVectorImpl<NonLocalDepResult> &Result, - DenseMap<BasicBlock*, Value*> &Visited, + DenseMap<BasicBlock *, Value *> &Visited, bool SkipFirstBlock = false); MemDepResult GetNonLocalInfoForBlock(Instruction *QueryInst, - const AliasAnalysis::Location &Loc, - bool isLoad, BasicBlock *BB, - NonLocalDepInfo *Cache, + const MemoryLocation &Loc, bool isLoad, + BasicBlock *BB, NonLocalDepInfo *Cache, unsigned NumSortedEntries); void RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair P); @@ -447,6 +445,6 @@ namespace llvm { }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/MemoryLocation.h b/include/llvm/Analysis/MemoryLocation.h index 94d938dc491f..ea69633a922c 100644 --- a/include/llvm/Analysis/MemoryLocation.h +++ b/include/llvm/Analysis/MemoryLocation.h @@ -26,6 +26,7 @@ class LoadInst; class StoreInst; class MemTransferInst; class MemIntrinsic; +class TargetLibraryInfo; /// Representation for a specific memory location. /// @@ -87,6 +88,10 @@ public: /// transfer. static MemoryLocation getForDest(const MemIntrinsic *MI); + /// Return a location representing a particular argument of a call. + static MemoryLocation getForArgument(ImmutableCallSite CS, unsigned ArgIdx, + const TargetLibraryInfo &TLI); + explicit MemoryLocation(const Value *Ptr = nullptr, uint64_t Size = UnknownSize, const AAMDNodes &AATags = AAMDNodes()) @@ -132,6 +137,6 @@ template <> struct DenseMapInfo<MemoryLocation> { return LHS == RHS; } }; -} +} // namespace llvm #endif diff --git a/include/llvm/Analysis/Passes.h b/include/llvm/Analysis/Passes.h index d112ab1823b4..ffaf871cf9e5 100644 --- a/include/llvm/Analysis/Passes.h +++ b/include/llvm/Analysis/Passes.h @@ -173,6 +173,6 @@ namespace llvm { // FunctionPass *createMemDerefPrinter(); -} +} // namespace llvm #endif diff --git a/include/llvm/Analysis/PostDominators.h b/include/llvm/Analysis/PostDominators.h index 0f7e2b88d2d7..f654652a97c3 100644 --- a/include/llvm/Analysis/PostDominators.h +++ b/include/llvm/Analysis/PostDominators.h @@ -112,6 +112,6 @@ template <> struct GraphTraits<PostDominatorTree*> } }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/PtrUseVisitor.h b/include/llvm/Analysis/PtrUseVisitor.h index 6e61fc3be384..8b5b90a3402e 100644 --- a/include/llvm/Analysis/PtrUseVisitor.h +++ b/include/llvm/Analysis/PtrUseVisitor.h @@ -280,6 +280,6 @@ protected: } }; -} +} // namespace llvm #endif diff --git a/include/llvm/Analysis/RegionInfo.h b/include/llvm/Analysis/RegionInfo.h index 7ceb086ee0a1..22fd1dfc0e78 100644 --- a/include/llvm/Analysis/RegionInfo.h +++ b/include/llvm/Analysis/RegionInfo.h @@ -906,5 +906,5 @@ EXTERN_TEMPLATE_INSTANTIATION(class RegionBase<RegionTraits<Function>>); EXTERN_TEMPLATE_INSTANTIATION(class RegionNodeBase<RegionTraits<Function>>); EXTERN_TEMPLATE_INSTANTIATION(class RegionInfoBase<RegionTraits<Function>>); -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/RegionPass.h b/include/llvm/Analysis/RegionPass.h index bd51c49e87db..5866fc5abc8c 100644 --- a/include/llvm/Analysis/RegionPass.h +++ b/include/llvm/Analysis/RegionPass.h @@ -123,6 +123,6 @@ public: } }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h index 1d1bd67b61ff..1c814084c090 100644 --- a/include/llvm/Analysis/ScalarEvolution.h +++ b/include/llvm/Analysis/ScalarEvolution.h @@ -981,6 +981,6 @@ namespace llvm { /// to locate them all and call their destructors. SCEVUnknown *FirstUnknown; }; -} +} // namespace llvm #endif diff --git a/include/llvm/Analysis/ScalarEvolutionExpander.h b/include/llvm/Analysis/ScalarEvolutionExpander.h index 8ec2078258d1..83493fad713b 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpander.h +++ b/include/llvm/Analysis/ScalarEvolutionExpander.h @@ -275,6 +275,6 @@ namespace llvm { Value *expandIVInc(PHINode *PN, Value *StepV, const Loop *L, Type *ExpandTy, Type *IntTy, bool useSubtract); }; -} +} // namespace llvm #endif diff --git a/include/llvm/Analysis/ScalarEvolutionExpressions.h b/include/llvm/Analysis/ScalarEvolutionExpressions.h index ff82db19b9e7..14feeed5c5dd 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpressions.h +++ b/include/llvm/Analysis/ScalarEvolutionExpressions.h @@ -829,6 +829,6 @@ static inline const SCEV *apply(const SCEV *Scev, LoopToScevMapT &Map, return SCEVApplyRewriter::rewrite(Scev, Map, SE); } -} +} // namespace llvm #endif diff --git a/include/llvm/Analysis/ScalarEvolutionNormalization.h b/include/llvm/Analysis/ScalarEvolutionNormalization.h index 7c6423a21cfa..4133864cc3c3 100644 --- a/include/llvm/Analysis/ScalarEvolutionNormalization.h +++ b/include/llvm/Analysis/ScalarEvolutionNormalization.h @@ -73,6 +73,6 @@ const SCEV *TransformForPostIncUse(TransformKind Kind, ScalarEvolution &SE, DominatorTree &DT); -} +} // namespace llvm #endif diff --git a/include/llvm/Analysis/TargetFolder.h b/include/llvm/Analysis/TargetFolder.h index 12bf9fe78a47..0e17a58069d7 100644 --- a/include/llvm/Analysis/TargetFolder.h +++ b/include/llvm/Analysis/TargetFolder.h @@ -265,6 +265,6 @@ public: } }; -} +} // namespace llvm #endif diff --git a/include/llvm/Analysis/TargetTransformInfo.h b/include/llvm/Analysis/TargetTransformInfo.h index 3700c9e4ac22..d863b4f76880 100644 --- a/include/llvm/Analysis/TargetTransformInfo.h +++ b/include/llvm/Analysis/TargetTransformInfo.h @@ -908,6 +908,6 @@ public: /// clients. ImmutablePass *createTargetTransformInfoWrapperPass(TargetIRAnalysis TIRA); -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/Analysis/TargetTransformInfoImpl.h b/include/llvm/Analysis/TargetTransformInfoImpl.h index e6a8a7690820..59b95a8da1e8 100644 --- a/include/llvm/Analysis/TargetTransformInfoImpl.h +++ b/include/llvm/Analysis/TargetTransformInfoImpl.h @@ -446,6 +446,6 @@ public: U->getNumOperands() == 1 ? U->getOperand(0)->getType() : nullptr); } }; -} +} // namespace llvm #endif |