diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
commit | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch) | |
tree | 012bb94d777798f1f56ac1cec429509766d05181 /contrib/libs/llvm12/include/llvm/Transforms/Utils | |
parent | 6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff) | |
download | ydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/llvm12/include/llvm/Transforms/Utils')
24 files changed, 1348 insertions, 1348 deletions
diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/BasicBlockUtils.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/BasicBlockUtils.h index 17376fd660..2b7016b7e6 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/BasicBlockUtils.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/BasicBlockUtils.h @@ -81,7 +81,7 @@ bool EliminateUnreachableBlocks(Function &F, DomTreeUpdater *DTU = nullptr, /// in it, fold them away. This handles the case when all entries to the PHI /// nodes in a block are guaranteed equal, such as when the block has exactly /// one predecessor. -bool FoldSingleEntryPHINodes(BasicBlock *BB, +bool FoldSingleEntryPHINodes(BasicBlock *BB, MemoryDependenceResults *MemDep = nullptr); /// Examine each PHI in the given block and delete it if it is dead. Also @@ -203,8 +203,8 @@ struct CriticalEdgeSplittingOptions { /// to. BasicBlock *SplitCriticalEdge(Instruction *TI, unsigned SuccNum, const CriticalEdgeSplittingOptions &Options = - CriticalEdgeSplittingOptions(), - const Twine &BBName = ""); + CriticalEdgeSplittingOptions(), + const Twine &BBName = ""); inline BasicBlock * SplitCriticalEdge(BasicBlock *BB, succ_iterator SI, @@ -252,72 +252,50 @@ unsigned SplitAllCriticalEdges(Function &F, const CriticalEdgeSplittingOptions &Options = CriticalEdgeSplittingOptions()); -/// Split the edge connecting the specified blocks, and return the newly created -/// basic block between \p From and \p To. +/// Split the edge connecting the specified blocks, and return the newly created +/// basic block between \p From and \p To. BasicBlock *SplitEdge(BasicBlock *From, BasicBlock *To, DominatorTree *DT = nullptr, LoopInfo *LI = nullptr, - MemorySSAUpdater *MSSAU = nullptr, - const Twine &BBName = ""); - -/// Split the specified block at the specified instruction. -/// -/// If \p Before is true, splitBlockBefore handles the block -/// splitting. Otherwise, execution proceeds as described below. -/// -/// Everything before \p SplitPt stays in \p Old and everything starting with \p -/// SplitPt moves to a new block. The two blocks are joined by an unconditional -/// branch. The new block with name \p BBName is returned. -/// -/// FIXME: deprecated, switch to the DomTreeUpdater-based one. -BasicBlock *SplitBlock(BasicBlock *Old, Instruction *SplitPt, DominatorTree *DT, - LoopInfo *LI = nullptr, - MemorySSAUpdater *MSSAU = nullptr, - const Twine &BBName = "", bool Before = false); - -/// Split the specified block at the specified instruction. -/// -/// If \p Before is true, splitBlockBefore handles the block -/// splitting. Otherwise, execution proceeds as described below. -/// -/// Everything before \p SplitPt stays in \p Old and everything starting with \p -/// SplitPt moves to a new block. The two blocks are joined by an unconditional -/// branch. The new block with name \p BBName is returned. + MemorySSAUpdater *MSSAU = nullptr, + const Twine &BBName = ""); + +/// Split the specified block at the specified instruction. +/// +/// If \p Before is true, splitBlockBefore handles the block +/// splitting. Otherwise, execution proceeds as described below. +/// +/// Everything before \p SplitPt stays in \p Old and everything starting with \p +/// SplitPt moves to a new block. The two blocks are joined by an unconditional +/// branch. The new block with name \p BBName is returned. +/// +/// FIXME: deprecated, switch to the DomTreeUpdater-based one. +BasicBlock *SplitBlock(BasicBlock *Old, Instruction *SplitPt, DominatorTree *DT, + LoopInfo *LI = nullptr, + MemorySSAUpdater *MSSAU = nullptr, + const Twine &BBName = "", bool Before = false); + +/// Split the specified block at the specified instruction. +/// +/// If \p Before is true, splitBlockBefore handles the block +/// splitting. Otherwise, execution proceeds as described below. +/// +/// Everything before \p SplitPt stays in \p Old and everything starting with \p +/// SplitPt moves to a new block. The two blocks are joined by an unconditional +/// branch. The new block with name \p BBName is returned. BasicBlock *SplitBlock(BasicBlock *Old, Instruction *SplitPt, - DomTreeUpdater *DTU = nullptr, LoopInfo *LI = nullptr, + DomTreeUpdater *DTU = nullptr, LoopInfo *LI = nullptr, MemorySSAUpdater *MSSAU = nullptr, - const Twine &BBName = "", bool Before = false); - -/// Split the specified block at the specified instruction \p SplitPt. -/// All instructions before \p SplitPt are moved to a new block and all -/// instructions after \p SplitPt stay in the old block. The new block and the -/// old block are joined by inserting an unconditional branch to the end of the -/// new block. The new block with name \p BBName is returned. -BasicBlock *splitBlockBefore(BasicBlock *Old, Instruction *SplitPt, - DomTreeUpdater *DTU, LoopInfo *LI, - MemorySSAUpdater *MSSAU, const Twine &BBName = ""); - -/// This method introduces at least one new basic block into the function and -/// moves some of the predecessors of BB to be predecessors of the new block. -/// The new predecessors are indicated by the Preds array. The new block is -/// given a suffix of 'Suffix'. Returns new basic block to which predecessors -/// from Preds are now pointing. -/// -/// If BB is a landingpad block then additional basicblock might be introduced. -/// It will have Suffix+".split_lp". See SplitLandingPadPredecessors for more -/// details on this case. -/// -/// This currently updates the LLVM IR, DominatorTree, LoopInfo, and LCCSA but -/// no other analyses. In particular, it does not preserve LoopSimplify -/// (because it's complicated to handle the case where one of the edges being -/// split is an exit of a loop with other exits). -/// -/// FIXME: deprecated, switch to the DomTreeUpdater-based one. -BasicBlock *SplitBlockPredecessors(BasicBlock *BB, ArrayRef<BasicBlock *> Preds, - const char *Suffix, DominatorTree *DT, - LoopInfo *LI = nullptr, - MemorySSAUpdater *MSSAU = nullptr, - bool PreserveLCSSA = false); - + const Twine &BBName = "", bool Before = false); + +/// Split the specified block at the specified instruction \p SplitPt. +/// All instructions before \p SplitPt are moved to a new block and all +/// instructions after \p SplitPt stay in the old block. The new block and the +/// old block are joined by inserting an unconditional branch to the end of the +/// new block. The new block with name \p BBName is returned. +BasicBlock *splitBlockBefore(BasicBlock *Old, Instruction *SplitPt, + DomTreeUpdater *DTU, LoopInfo *LI, + MemorySSAUpdater *MSSAU, const Twine &BBName = ""); + /// This method introduces at least one new basic block into the function and /// moves some of the predecessors of BB to be predecessors of the new block. /// The new predecessors are indicated by the Preds array. The new block is @@ -332,9 +310,31 @@ BasicBlock *SplitBlockPredecessors(BasicBlock *BB, ArrayRef<BasicBlock *> Preds, /// no other analyses. In particular, it does not preserve LoopSimplify /// (because it's complicated to handle the case where one of the edges being /// split is an exit of a loop with other exits). +/// +/// FIXME: deprecated, switch to the DomTreeUpdater-based one. BasicBlock *SplitBlockPredecessors(BasicBlock *BB, ArrayRef<BasicBlock *> Preds, + const char *Suffix, DominatorTree *DT, + LoopInfo *LI = nullptr, + MemorySSAUpdater *MSSAU = nullptr, + bool PreserveLCSSA = false); + +/// This method introduces at least one new basic block into the function and +/// moves some of the predecessors of BB to be predecessors of the new block. +/// The new predecessors are indicated by the Preds array. The new block is +/// given a suffix of 'Suffix'. Returns new basic block to which predecessors +/// from Preds are now pointing. +/// +/// If BB is a landingpad block then additional basicblock might be introduced. +/// It will have Suffix+".split_lp". See SplitLandingPadPredecessors for more +/// details on this case. +/// +/// This currently updates the LLVM IR, DominatorTree, LoopInfo, and LCCSA but +/// no other analyses. In particular, it does not preserve LoopSimplify +/// (because it's complicated to handle the case where one of the edges being +/// split is an exit of a loop with other exits). +BasicBlock *SplitBlockPredecessors(BasicBlock *BB, ArrayRef<BasicBlock *> Preds, const char *Suffix, - DomTreeUpdater *DTU = nullptr, + DomTreeUpdater *DTU = nullptr, LoopInfo *LI = nullptr, MemorySSAUpdater *MSSAU = nullptr, bool PreserveLCSSA = false); @@ -350,31 +350,31 @@ BasicBlock *SplitBlockPredecessors(BasicBlock *BB, ArrayRef<BasicBlock *> Preds, /// no other analyses. In particular, it does not preserve LoopSimplify /// (because it's complicated to handle the case where one of the edges being /// split is an exit of a loop with other exits). -/// -/// FIXME: deprecated, switch to the DomTreeUpdater-based one. -void SplitLandingPadPredecessors(BasicBlock *OrigBB, - ArrayRef<BasicBlock *> Preds, - const char *Suffix, const char *Suffix2, - SmallVectorImpl<BasicBlock *> &NewBBs, - DominatorTree *DT, LoopInfo *LI = nullptr, - MemorySSAUpdater *MSSAU = nullptr, - bool PreserveLCSSA = false); - -/// This method transforms the landing pad, OrigBB, by introducing two new basic -/// blocks into the function. One of those new basic blocks gets the -/// predecessors listed in Preds. The other basic block gets the remaining -/// predecessors of OrigBB. The landingpad instruction OrigBB is clone into both -/// of the new basic blocks. The new blocks are given the suffixes 'Suffix1' and -/// 'Suffix2', and are returned in the NewBBs vector. -/// -/// This currently updates the LLVM IR, DominatorTree, LoopInfo, and LCCSA but -/// no other analyses. In particular, it does not preserve LoopSimplify -/// (because it's complicated to handle the case where one of the edges being -/// split is an exit of a loop with other exits). +/// +/// FIXME: deprecated, switch to the DomTreeUpdater-based one. +void SplitLandingPadPredecessors(BasicBlock *OrigBB, + ArrayRef<BasicBlock *> Preds, + const char *Suffix, const char *Suffix2, + SmallVectorImpl<BasicBlock *> &NewBBs, + DominatorTree *DT, LoopInfo *LI = nullptr, + MemorySSAUpdater *MSSAU = nullptr, + bool PreserveLCSSA = false); + +/// This method transforms the landing pad, OrigBB, by introducing two new basic +/// blocks into the function. One of those new basic blocks gets the +/// predecessors listed in Preds. The other basic block gets the remaining +/// predecessors of OrigBB. The landingpad instruction OrigBB is clone into both +/// of the new basic blocks. The new blocks are given the suffixes 'Suffix1' and +/// 'Suffix2', and are returned in the NewBBs vector. +/// +/// This currently updates the LLVM IR, DominatorTree, LoopInfo, and LCCSA but +/// no other analyses. In particular, it does not preserve LoopSimplify +/// (because it's complicated to handle the case where one of the edges being +/// split is an exit of a loop with other exits). void SplitLandingPadPredecessors( BasicBlock *OrigBB, ArrayRef<BasicBlock *> Preds, const char *Suffix, const char *Suffix2, SmallVectorImpl<BasicBlock *> &NewBBs, - DomTreeUpdater *DTU = nullptr, LoopInfo *LI = nullptr, + DomTreeUpdater *DTU = nullptr, LoopInfo *LI = nullptr, MemorySSAUpdater *MSSAU = nullptr, bool PreserveLCSSA = false); /// This method duplicates the specified return instruction into a predecessor @@ -406,39 +406,39 @@ ReturnInst *FoldReturnIntoUncondBranch(ReturnInst *RI, BasicBlock *BB, /// Returns the NewBasicBlock's terminator. /// /// Updates DT and LI if given. -/// -/// FIXME: deprecated, switch to the DomTreeUpdater-based one. -Instruction *SplitBlockAndInsertIfThen(Value *Cond, Instruction *SplitBefore, - bool Unreachable, MDNode *BranchWeights, - DominatorTree *DT, - LoopInfo *LI = nullptr, - BasicBlock *ThenBlock = nullptr); - -/// Split the containing block at the specified instruction - everything before -/// SplitBefore stays in the old basic block, and the rest of the instructions -/// in the BB are moved to a new block. The two blocks are connected by a -/// conditional branch (with value of Cmp being the condition). -/// Before: -/// Head -/// SplitBefore -/// Tail -/// After: -/// Head -/// if (Cond) -/// ThenBlock -/// SplitBefore -/// Tail -/// -/// If \p ThenBlock is not specified, a new block will be created for it. -/// If \p Unreachable is true, the newly created block will end with -/// UnreachableInst, otherwise it branches to Tail. -/// Returns the NewBasicBlock's terminator. -/// -/// Updates DT and LI if given. +/// +/// FIXME: deprecated, switch to the DomTreeUpdater-based one. Instruction *SplitBlockAndInsertIfThen(Value *Cond, Instruction *SplitBefore, + bool Unreachable, MDNode *BranchWeights, + DominatorTree *DT, + LoopInfo *LI = nullptr, + BasicBlock *ThenBlock = nullptr); + +/// Split the containing block at the specified instruction - everything before +/// SplitBefore stays in the old basic block, and the rest of the instructions +/// in the BB are moved to a new block. The two blocks are connected by a +/// conditional branch (with value of Cmp being the condition). +/// Before: +/// Head +/// SplitBefore +/// Tail +/// After: +/// Head +/// if (Cond) +/// ThenBlock +/// SplitBefore +/// Tail +/// +/// If \p ThenBlock is not specified, a new block will be created for it. +/// If \p Unreachable is true, the newly created block will end with +/// UnreachableInst, otherwise it branches to Tail. +/// Returns the NewBasicBlock's terminator. +/// +/// Updates DT and LI if given. +Instruction *SplitBlockAndInsertIfThen(Value *Cond, Instruction *SplitBefore, bool Unreachable, MDNode *BranchWeights = nullptr, - DomTreeUpdater *DTU = nullptr, + DomTreeUpdater *DTU = nullptr, LoopInfo *LI = nullptr, BasicBlock *ThenBlock = nullptr); diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/BuildLibCalls.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/BuildLibCalls.h index edb268a5b1..173218b15c 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/BuildLibCalls.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/BuildLibCalls.h @@ -103,10 +103,10 @@ namespace llvm { IRBuilderBase &B, const DataLayout &DL, const TargetLibraryInfo *TLI); - /// Emit a call to the mempcpy function. - Value *emitMemPCpy(Value *Dst, Value *Src, Value *Len, IRBuilderBase &B, - const DataLayout &DL, const TargetLibraryInfo *TLI); - + /// Emit a call to the mempcpy function. + Value *emitMemPCpy(Value *Dst, Value *Src, Value *Len, IRBuilderBase &B, + const DataLayout &DL, const TargetLibraryInfo *TLI); + /// Emit a call to the memchr function. This assumes that Ptr is a pointer, /// Val is an i32 value, and Len is an 'intptr_t' value. Value *emitMemChr(Value *Ptr, Value *Val, Value *Len, IRBuilderBase &B, diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/CallGraphUpdater.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/CallGraphUpdater.h index 52b14df3ed..520a4de374 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/CallGraphUpdater.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/CallGraphUpdater.h @@ -94,7 +94,7 @@ public: /// If a new function was created by outlining, this method can be called /// to update the call graph for the new function. Note that the old one /// still needs to be re-analyzed or manually updated. - void registerOutlinedFunction(Function &OriginalFn, Function &NewFn); + void registerOutlinedFunction(Function &OriginalFn, Function &NewFn); /// Replace \p OldFn in the call graph (and SCC) with \p NewFn. The uses /// outside the call graph and the function \p OldFn are not modified. diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/Cloning.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/Cloning.h index 55e8d5d0b2..d15d6828ce 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/Cloning.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/Cloning.h @@ -275,49 +275,49 @@ void updateProfileCallee( Function *Callee, int64_t entryDelta, const ValueMap<const Value *, WeakTrackingVH> *VMap = nullptr); -/// Find the 'llvm.experimental.noalias.scope.decl' intrinsics in the specified -/// basic blocks and extract their scope. These are candidates for duplication -/// when cloning. -void identifyNoAliasScopesToClone( - ArrayRef<BasicBlock *> BBs, SmallVectorImpl<MDNode *> &NoAliasDeclScopes); - -/// Find the 'llvm.experimental.noalias.scope.decl' intrinsics in the specified -/// instruction range and extract their scope. These are candidates for -/// duplication when cloning. -void identifyNoAliasScopesToClone( - BasicBlock::iterator Start, BasicBlock::iterator End, - SmallVectorImpl<MDNode *> &NoAliasDeclScopes); - -/// Duplicate the specified list of noalias decl scopes. -/// The 'Ext' string is added as an extension to the name. -/// Afterwards, the ClonedScopes contains the mapping of the original scope -/// MDNode onto the cloned scope. -/// Be aware that the cloned scopes are still part of the original scope domain. -void cloneNoAliasScopes( - ArrayRef<MDNode *> NoAliasDeclScopes, - DenseMap<MDNode *, MDNode *> &ClonedScopes, - StringRef Ext, LLVMContext &Context); - -/// Adapt the metadata for the specified instruction according to the -/// provided mapping. This is normally used after cloning an instruction, when -/// some noalias scopes needed to be cloned. -void adaptNoAliasScopes( - llvm::Instruction *I, const DenseMap<MDNode *, MDNode *> &ClonedScopes, - LLVMContext &Context); - -/// Clone the specified noalias decl scopes. Then adapt all instructions in the -/// NewBlocks basicblocks to the cloned versions. -/// 'Ext' will be added to the duplicate scope names. -void cloneAndAdaptNoAliasScopes(ArrayRef<MDNode *> NoAliasDeclScopes, - ArrayRef<BasicBlock *> NewBlocks, - LLVMContext &Context, StringRef Ext); - -/// Clone the specified noalias decl scopes. Then adapt all instructions in the -/// [IStart, IEnd] (IEnd included !) range to the cloned versions. 'Ext' will be -/// added to the duplicate scope names. -void cloneAndAdaptNoAliasScopes(ArrayRef<MDNode *> NoAliasDeclScopes, - Instruction *IStart, Instruction *IEnd, - LLVMContext &Context, StringRef Ext); +/// Find the 'llvm.experimental.noalias.scope.decl' intrinsics in the specified +/// basic blocks and extract their scope. These are candidates for duplication +/// when cloning. +void identifyNoAliasScopesToClone( + ArrayRef<BasicBlock *> BBs, SmallVectorImpl<MDNode *> &NoAliasDeclScopes); + +/// Find the 'llvm.experimental.noalias.scope.decl' intrinsics in the specified +/// instruction range and extract their scope. These are candidates for +/// duplication when cloning. +void identifyNoAliasScopesToClone( + BasicBlock::iterator Start, BasicBlock::iterator End, + SmallVectorImpl<MDNode *> &NoAliasDeclScopes); + +/// Duplicate the specified list of noalias decl scopes. +/// The 'Ext' string is added as an extension to the name. +/// Afterwards, the ClonedScopes contains the mapping of the original scope +/// MDNode onto the cloned scope. +/// Be aware that the cloned scopes are still part of the original scope domain. +void cloneNoAliasScopes( + ArrayRef<MDNode *> NoAliasDeclScopes, + DenseMap<MDNode *, MDNode *> &ClonedScopes, + StringRef Ext, LLVMContext &Context); + +/// Adapt the metadata for the specified instruction according to the +/// provided mapping. This is normally used after cloning an instruction, when +/// some noalias scopes needed to be cloned. +void adaptNoAliasScopes( + llvm::Instruction *I, const DenseMap<MDNode *, MDNode *> &ClonedScopes, + LLVMContext &Context); + +/// Clone the specified noalias decl scopes. Then adapt all instructions in the +/// NewBlocks basicblocks to the cloned versions. +/// 'Ext' will be added to the duplicate scope names. +void cloneAndAdaptNoAliasScopes(ArrayRef<MDNode *> NoAliasDeclScopes, + ArrayRef<BasicBlock *> NewBlocks, + LLVMContext &Context, StringRef Ext); + +/// Clone the specified noalias decl scopes. Then adapt all instructions in the +/// [IStart, IEnd] (IEnd included !) range to the cloned versions. 'Ext' will be +/// added to the duplicate scope names. +void cloneAndAdaptNoAliasScopes(ArrayRef<MDNode *> NoAliasDeclScopes, + Instruction *IStart, Instruction *IEnd, + LLVMContext &Context, StringRef Ext); } // end namespace llvm #endif // LLVM_TRANSFORMS_UTILS_CLONING_H diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/Debugify.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/Debugify.h index 7fc4011991..c09449953d 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/Debugify.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/Debugify.h @@ -20,11 +20,11 @@ #ifndef LLVM_TRANSFORM_UTILS_DEBUGIFY_H #define LLVM_TRANSFORM_UTILS_DEBUGIFY_H -#include "llvm/ADT/MapVector.h" +#include "llvm/ADT/MapVector.h" #include "llvm/ADT/StringRef.h" -#include "llvm/Bitcode/BitcodeWriterPass.h" -#include "llvm/IR/IRPrintingPasses.h" -#include "llvm/IR/LegacyPassManager.h" +#include "llvm/Bitcode/BitcodeWriterPass.h" +#include "llvm/IR/IRPrintingPasses.h" +#include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/PassManager.h" namespace llvm { @@ -82,8 +82,8 @@ struct DebugifyStatistics { /// Map pass names to a per-pass DebugifyStatistics instance. using DebugifyStatsMap = llvm::MapVector<llvm::StringRef, DebugifyStatistics>; -void exportDebugifyStats(StringRef Path, const DebugifyStatsMap &Map); - +void exportDebugifyStats(StringRef Path, const DebugifyStatsMap &Map); + llvm::ModulePass * createCheckDebugifyModulePass(bool Strip = false, llvm::StringRef NameOfWrappedPass = "", @@ -99,62 +99,62 @@ struct NewPMCheckDebugifyPass llvm::PreservedAnalyses run(llvm::Module &M, llvm::ModuleAnalysisManager &AM); }; -struct DebugifyEachInstrumentation { - DebugifyStatsMap StatsMap; - - void registerCallbacks(PassInstrumentationCallbacks &PIC); -}; - -/// DebugifyCustomPassManager wraps each pass with the debugify passes if -/// needed. -/// NOTE: We support legacy custom pass manager only. -/// TODO: Add New PM support for custom pass manager. -class DebugifyCustomPassManager : public legacy::PassManager { - DebugifyStatsMap DIStatsMap; - bool EnableDebugifyEach = false; - -public: - using super = legacy::PassManager; - - void add(Pass *P) override { - // Wrap each pass with (-check)-debugify passes if requested, making - // exceptions for passes which shouldn't see -debugify instrumentation. - bool WrapWithDebugify = EnableDebugifyEach && !P->getAsImmutablePass() && - !isIRPrintingPass(P) && !isBitcodeWriterPass(P); - if (!WrapWithDebugify) { - super::add(P); - return; - } - - // Apply -debugify/-check-debugify before/after each pass and collect - // debug info loss statistics. - PassKind Kind = P->getPassKind(); - StringRef Name = P->getPassName(); - - // TODO: Implement Debugify for LoopPass. - switch (Kind) { - case PT_Function: - super::add(createDebugifyFunctionPass()); - super::add(P); - super::add(createCheckDebugifyFunctionPass(true, Name, &DIStatsMap)); - break; - case PT_Module: - super::add(createDebugifyModulePass()); - super::add(P); - super::add(createCheckDebugifyModulePass(true, Name, &DIStatsMap)); - break; - default: - super::add(P); - break; - } - } - - void enableDebugifyEach() { EnableDebugifyEach = true; } - - const DebugifyStatsMap &getDebugifyStatsMap() const { return DIStatsMap; } -}; -} // namespace llvm - +struct DebugifyEachInstrumentation { + DebugifyStatsMap StatsMap; + + void registerCallbacks(PassInstrumentationCallbacks &PIC); +}; + +/// DebugifyCustomPassManager wraps each pass with the debugify passes if +/// needed. +/// NOTE: We support legacy custom pass manager only. +/// TODO: Add New PM support for custom pass manager. +class DebugifyCustomPassManager : public legacy::PassManager { + DebugifyStatsMap DIStatsMap; + bool EnableDebugifyEach = false; + +public: + using super = legacy::PassManager; + + void add(Pass *P) override { + // Wrap each pass with (-check)-debugify passes if requested, making + // exceptions for passes which shouldn't see -debugify instrumentation. + bool WrapWithDebugify = EnableDebugifyEach && !P->getAsImmutablePass() && + !isIRPrintingPass(P) && !isBitcodeWriterPass(P); + if (!WrapWithDebugify) { + super::add(P); + return; + } + + // Apply -debugify/-check-debugify before/after each pass and collect + // debug info loss statistics. + PassKind Kind = P->getPassKind(); + StringRef Name = P->getPassName(); + + // TODO: Implement Debugify for LoopPass. + switch (Kind) { + case PT_Function: + super::add(createDebugifyFunctionPass()); + super::add(P); + super::add(createCheckDebugifyFunctionPass(true, Name, &DIStatsMap)); + break; + case PT_Module: + super::add(createDebugifyModulePass()); + super::add(P); + super::add(createCheckDebugifyModulePass(true, Name, &DIStatsMap)); + break; + default: + super::add(P); + break; + } + } + + void enableDebugifyEach() { EnableDebugifyEach = true; } + + const DebugifyStatsMap &getDebugifyStatsMap() const { return DIStatsMap; } +}; +} // namespace llvm + #endif // LLVM_TRANSFORM_UTILS_DEBUGIFY_H #ifdef __GNUC__ diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/FixIrreducible.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/FixIrreducible.h index 6417ea5882..cdd35469b1 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/FixIrreducible.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/FixIrreducible.h @@ -1,31 +1,31 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- FixIrreducible.h - Convert irreducible control-flow into loops -----===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TRANSFORMS_UTILS_FIXIRREDUCIBLE_H -#define LLVM_TRANSFORMS_UTILS_FIXIRREDUCIBLE_H - -#include "llvm/IR/PassManager.h" - -namespace llvm { -struct FixIrreduciblePass : PassInfoMixin<FixIrreduciblePass> { - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); -}; -} // namespace llvm - -#endif // LLVM_TRANSFORMS_UTILS_FIXIRREDUCIBLE_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- FixIrreducible.h - Convert irreducible control-flow into loops -----===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_TRANSFORMS_UTILS_FIXIRREDUCIBLE_H +#define LLVM_TRANSFORMS_UTILS_FIXIRREDUCIBLE_H + +#include "llvm/IR/PassManager.h" + +namespace llvm { +struct FixIrreduciblePass : PassInfoMixin<FixIrreduciblePass> { + PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); +}; +} // namespace llvm + +#endif // LLVM_TRANSFORMS_UTILS_FIXIRREDUCIBLE_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/InstructionNamer.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/InstructionNamer.h index c9ede371d9..e755bf4087 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/InstructionNamer.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/InstructionNamer.h @@ -1,31 +1,31 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- InstructionNamer.h - Give anonymous instructions names -------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TRANSFORMS_UTILS_INSTRUCTIONNAMER_H -#define LLVM_TRANSFORMS_UTILS_INSTRUCTIONNAMER_H - -#include "llvm/IR/PassManager.h" - -namespace llvm { -struct InstructionNamerPass : PassInfoMixin<InstructionNamerPass> { - PreservedAnalyses run(Function &, FunctionAnalysisManager &); -}; -} // namespace llvm - -#endif // LLVM_TRANSFORMS_UTILS_INSTRUCTIONNAMER_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- InstructionNamer.h - Give anonymous instructions names -------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_TRANSFORMS_UTILS_INSTRUCTIONNAMER_H +#define LLVM_TRANSFORMS_UTILS_INSTRUCTIONNAMER_H + +#include "llvm/IR/PassManager.h" + +namespace llvm { +struct InstructionNamerPass : PassInfoMixin<InstructionNamerPass> { + PreservedAnalyses run(Function &, FunctionAnalysisManager &); +}; +} // namespace llvm + +#endif // LLVM_TRANSFORMS_UTILS_INSTRUCTIONNAMER_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/Local.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/Local.h index 9c76913256..40cf2cb596 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/Local.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/Local.h @@ -36,8 +36,8 @@ #include "llvm/IR/Value.h" #include "llvm/IR/ValueHandle.h" #include "llvm/Support/Casting.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Transforms/Utils/SimplifyCFGOptions.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Transforms/Utils/SimplifyCFGOptions.h" #include <cstdint> #include <limits> @@ -101,9 +101,9 @@ bool wouldInstructionBeTriviallyDead(Instruction *I, /// recursively. Return true if any instructions were deleted. bool RecursivelyDeleteTriviallyDeadInstructions( Value *V, const TargetLibraryInfo *TLI = nullptr, - MemorySSAUpdater *MSSAU = nullptr, - std::function<void(Value *)> AboutToDeleteCallback = - std::function<void(Value *)>()); + MemorySSAUpdater *MSSAU = nullptr, + std::function<void(Value *)> AboutToDeleteCallback = + std::function<void(Value *)>()); /// Delete all of the instructions in `DeadInsts`, and all other instructions /// that deleting these in turn causes to be trivially dead. @@ -115,9 +115,9 @@ bool RecursivelyDeleteTriviallyDeadInstructions( /// empty afterward. void RecursivelyDeleteTriviallyDeadInstructions( SmallVectorImpl<WeakTrackingVH> &DeadInsts, - const TargetLibraryInfo *TLI = nullptr, MemorySSAUpdater *MSSAU = nullptr, - std::function<void(Value *)> AboutToDeleteCallback = - std::function<void(Value *)>()); + const TargetLibraryInfo *TLI = nullptr, MemorySSAUpdater *MSSAU = nullptr, + std::function<void(Value *)> AboutToDeleteCallback = + std::function<void(Value *)>()); /// Same functionality as RecursivelyDeleteTriviallyDeadInstructions, but allow /// instructions that are not trivially dead. These will be ignored. @@ -125,9 +125,9 @@ void RecursivelyDeleteTriviallyDeadInstructions( /// were found and deleted. bool RecursivelyDeleteTriviallyDeadInstructionsPermissive( SmallVectorImpl<WeakTrackingVH> &DeadInsts, - const TargetLibraryInfo *TLI = nullptr, MemorySSAUpdater *MSSAU = nullptr, - std::function<void(Value *)> AboutToDeleteCallback = - std::function<void(Value *)>()); + const TargetLibraryInfo *TLI = nullptr, MemorySSAUpdater *MSSAU = nullptr, + std::function<void(Value *)> AboutToDeleteCallback = + std::function<void(Value *)>()); /// If the specified value is an effectively dead PHI node, due to being a /// def-use chain of single-use nodes that either forms a cycle or is terminated @@ -179,11 +179,11 @@ bool EliminateDuplicatePHINodes(BasicBlock *BB); /// It returns true if a modification was made, possibly deleting the basic /// block that was pointed to. LoopHeaders is an optional input parameter /// providing the set of loop headers that SimplifyCFG should not eliminate. -extern cl::opt<bool> RequireAndPreserveDomTree; +extern cl::opt<bool> RequireAndPreserveDomTree; bool simplifyCFG(BasicBlock *BB, const TargetTransformInfo &TTI, - DomTreeUpdater *DTU = nullptr, + DomTreeUpdater *DTU = nullptr, const SimplifyCFGOptions &Options = {}, - ArrayRef<WeakVH> LoopHeaders = {}); + ArrayRef<WeakVH> LoopHeaders = {}); /// This function is used to flatten a CFG. For example, it uses parallel-and /// and parallel-or mode to collapse if-conditions and merge if-regions with @@ -193,9 +193,9 @@ bool FlattenCFG(BasicBlock *BB, AAResults *AA = nullptr); /// If this basic block is ONLY a setcc and a branch, and if a predecessor /// branches to us and one of our successors, fold the setcc into the /// predecessor and use logical operations to pick the right destination. -bool FoldBranchToCommonDest(BranchInst *BI, llvm::DomTreeUpdater *DTU = nullptr, - MemorySSAUpdater *MSSAU = nullptr, - const TargetTransformInfo *TTI = nullptr, +bool FoldBranchToCommonDest(BranchInst *BI, llvm::DomTreeUpdater *DTU = nullptr, + MemorySSAUpdater *MSSAU = nullptr, + const TargetTransformInfo *TTI = nullptr, unsigned BonusInstThreshold = 1); /// This function takes a virtual register computed by an Instruction and @@ -339,13 +339,13 @@ DIExpression *salvageDebugInfoImpl(Instruction &I, DIExpression *DIExpr, bool replaceAllDbgUsesWith(Instruction &From, Value &To, Instruction &DomPoint, DominatorTree &DT); -/// Remove all instructions from a basic block other than its terminator -/// and any present EH pad instructions. Returns a pair where the first element -/// is the number of instructions (excluding debug info instrinsics) that have -/// been removed, and the second element is the number of debug info intrinsics -/// that have been removed. -std::pair<unsigned, unsigned> -removeAllNonTerminatorAndEHPadInstructions(BasicBlock *BB); +/// Remove all instructions from a basic block other than its terminator +/// and any present EH pad instructions. Returns a pair where the first element +/// is the number of instructions (excluding debug info instrinsics) that have +/// been removed, and the second element is the number of debug info intrinsics +/// that have been removed. +std::pair<unsigned, unsigned> +removeAllNonTerminatorAndEHPadInstructions(BasicBlock *BB); /// Insert an unreachable instruction before the specified /// instruction, making it and the rest of the code in the block dead. diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopPeel.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopPeel.h index df15ce4fca..913345fe1e 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopPeel.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopPeel.h @@ -1,51 +1,51 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- llvm/Transforms/Utils/LoopPeel.h ----- Peeling utilities -*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This file defines some loop peeling utilities. It does not define any -// actual pass or policy. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TRANSFORMS_UTILS_LOOPPEEL_H -#define LLVM_TRANSFORMS_UTILS_LOOPPEEL_H - -#include "llvm/Analysis/TargetTransformInfo.h" - -namespace llvm { - -bool canPeel(Loop *L); - -bool peelLoop(Loop *L, unsigned PeelCount, LoopInfo *LI, ScalarEvolution *SE, - DominatorTree *DT, AssumptionCache *AC, bool PreserveLCSSA); - -TargetTransformInfo::PeelingPreferences -gatherPeelingPreferences(Loop *L, ScalarEvolution &SE, - const TargetTransformInfo &TTI, - Optional<bool> UserAllowPeeling, - Optional<bool> UserAllowProfileBasedPeeling, - bool UnrollingSpecficValues = false); - -void computePeelCount(Loop *L, unsigned LoopSize, - TargetTransformInfo::PeelingPreferences &PP, - unsigned &TripCount, ScalarEvolution &SE, - unsigned Threshold = UINT_MAX); - -} // end namespace llvm - -#endif // LLVM_TRANSFORMS_UTILS_LOOPPEEL_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- llvm/Transforms/Utils/LoopPeel.h ----- Peeling utilities -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines some loop peeling utilities. It does not define any +// actual pass or policy. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_TRANSFORMS_UTILS_LOOPPEEL_H +#define LLVM_TRANSFORMS_UTILS_LOOPPEEL_H + +#include "llvm/Analysis/TargetTransformInfo.h" + +namespace llvm { + +bool canPeel(Loop *L); + +bool peelLoop(Loop *L, unsigned PeelCount, LoopInfo *LI, ScalarEvolution *SE, + DominatorTree *DT, AssumptionCache *AC, bool PreserveLCSSA); + +TargetTransformInfo::PeelingPreferences +gatherPeelingPreferences(Loop *L, ScalarEvolution &SE, + const TargetTransformInfo &TTI, + Optional<bool> UserAllowPeeling, + Optional<bool> UserAllowProfileBasedPeeling, + bool UnrollingSpecficValues = false); + +void computePeelCount(Loop *L, unsigned LoopSize, + TargetTransformInfo::PeelingPreferences &PP, + unsigned &TripCount, ScalarEvolution &SE, + unsigned Threshold = UINT_MAX); + +} // end namespace llvm + +#endif // LLVM_TRANSFORMS_UTILS_LOOPPEEL_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopRotationUtils.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopRotationUtils.h index acfbf03d02..b13b8c79b0 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopRotationUtils.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopRotationUtils.h @@ -40,8 +40,8 @@ class TargetTransformInfo; bool LoopRotation(Loop *L, LoopInfo *LI, const TargetTransformInfo *TTI, AssumptionCache *AC, DominatorTree *DT, ScalarEvolution *SE, MemorySSAUpdater *MSSAU, const SimplifyQuery &SQ, - bool RotationOnly, unsigned Threshold, bool IsUtilMode, - bool PrepareForLTO = false); + bool RotationOnly, unsigned Threshold, bool IsUtilMode, + bool PrepareForLTO = false); } // namespace llvm diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopUtils.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopUtils.h index dc655420b5..f3d2d970b9 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopUtils.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopUtils.h @@ -33,8 +33,8 @@ class AAResults; class AliasSet; class AliasSetTracker; class BasicBlock; -class BlockFrequencyInfo; -class ICFLoopSafetyInfo; +class BlockFrequencyInfo; +class ICFLoopSafetyInfo; class IRBuilderBase; class Loop; class LoopInfo; @@ -82,14 +82,14 @@ bool formDedicatedExitBlocks(Loop *L, DominatorTree *DT, LoopInfo *LI, /// changes to CFG, preserved. /// /// Returns true if any modifications are made. -/// -/// This function may introduce unused PHI nodes. If \p PHIsToRemove is not -/// nullptr, those are added to it (before removing, the caller has to check if -/// they still do not have any uses). Otherwise the PHIs are directly removed. -bool formLCSSAForInstructions( - SmallVectorImpl<Instruction *> &Worklist, const DominatorTree &DT, - const LoopInfo &LI, ScalarEvolution *SE, IRBuilderBase &Builder, - SmallVectorImpl<PHINode *> *PHIsToRemove = nullptr); +/// +/// This function may introduce unused PHI nodes. If \p PHIsToRemove is not +/// nullptr, those are added to it (before removing, the caller has to check if +/// they still do not have any uses). Otherwise the PHIs are directly removed. +bool formLCSSAForInstructions( + SmallVectorImpl<Instruction *> &Worklist, const DominatorTree &DT, + const LoopInfo &LI, ScalarEvolution *SE, IRBuilderBase &Builder, + SmallVectorImpl<PHINode *> *PHIsToRemove = nullptr); /// Put loop into LCSSA form. /// @@ -118,28 +118,28 @@ bool formLCSSA(Loop &L, const DominatorTree &DT, const LoopInfo *LI, bool formLCSSARecursively(Loop &L, const DominatorTree &DT, const LoopInfo *LI, ScalarEvolution *SE); -/// Flags controlling how much is checked when sinking or hoisting -/// instructions. The number of memory access in the loop (and whether there -/// are too many) is determined in the constructors when using MemorySSA. -class SinkAndHoistLICMFlags { -public: - // Explicitly set limits. - SinkAndHoistLICMFlags(unsigned LicmMssaOptCap, - unsigned LicmMssaNoAccForPromotionCap, bool IsSink, - Loop *L = nullptr, MemorySSA *MSSA = nullptr); - // Use default limits. - SinkAndHoistLICMFlags(bool IsSink, Loop *L = nullptr, - MemorySSA *MSSA = nullptr); - - void setIsSink(bool B) { IsSink = B; } - bool getIsSink() { return IsSink; } - bool tooManyMemoryAccesses() { return NoOfMemAccTooLarge; } - bool tooManyClobberingCalls() { return LicmMssaOptCounter >= LicmMssaOptCap; } - void incrementClobberingCalls() { ++LicmMssaOptCounter; } - -protected: - bool NoOfMemAccTooLarge = false; - unsigned LicmMssaOptCounter = 0; +/// Flags controlling how much is checked when sinking or hoisting +/// instructions. The number of memory access in the loop (and whether there +/// are too many) is determined in the constructors when using MemorySSA. +class SinkAndHoistLICMFlags { +public: + // Explicitly set limits. + SinkAndHoistLICMFlags(unsigned LicmMssaOptCap, + unsigned LicmMssaNoAccForPromotionCap, bool IsSink, + Loop *L = nullptr, MemorySSA *MSSA = nullptr); + // Use default limits. + SinkAndHoistLICMFlags(bool IsSink, Loop *L = nullptr, + MemorySSA *MSSA = nullptr); + + void setIsSink(bool B) { IsSink = B; } + bool getIsSink() { return IsSink; } + bool tooManyMemoryAccesses() { return NoOfMemAccTooLarge; } + bool tooManyClobberingCalls() { return LicmMssaOptCounter >= LicmMssaOptCap; } + void incrementClobberingCalls() { ++LicmMssaOptCounter; } + +protected: + bool NoOfMemAccTooLarge = false; + unsigned LicmMssaOptCounter = 0; unsigned LicmMssaOptCap; unsigned LicmMssaNoAccForPromotionCap; bool IsSink; @@ -150,13 +150,13 @@ protected: /// reverse depth first order w.r.t the DominatorTree. This allows us to visit /// uses before definitions, allowing us to sink a loop body in one pass without /// iteration. Takes DomTreeNode, AAResults, LoopInfo, DominatorTree, -/// BlockFrequencyInfo, TargetLibraryInfo, Loop, AliasSet information for all +/// BlockFrequencyInfo, TargetLibraryInfo, Loop, AliasSet information for all /// instructions of the loop and loop safety information as /// arguments. Diagnostics is emitted via \p ORE. It returns changed status. bool sinkRegion(DomTreeNode *, AAResults *, LoopInfo *, DominatorTree *, - BlockFrequencyInfo *, TargetLibraryInfo *, - TargetTransformInfo *, Loop *, AliasSetTracker *, - MemorySSAUpdater *, ICFLoopSafetyInfo *, + BlockFrequencyInfo *, TargetLibraryInfo *, + TargetTransformInfo *, Loop *, AliasSetTracker *, + MemorySSAUpdater *, ICFLoopSafetyInfo *, SinkAndHoistLICMFlags &, OptimizationRemarkEmitter *); /// Walk the specified region of the CFG (defined by all blocks @@ -164,14 +164,14 @@ bool sinkRegion(DomTreeNode *, AAResults *, LoopInfo *, DominatorTree *, /// first order w.r.t the DominatorTree. This allows us to visit definitions /// before uses, allowing us to hoist a loop body in one pass without iteration. /// Takes DomTreeNode, AAResults, LoopInfo, DominatorTree, -/// BlockFrequencyInfo, TargetLibraryInfo, Loop, AliasSet information for all -/// instructions of the loop and loop safety information as arguments. -/// Diagnostics is emitted via \p ORE. It returns changed status. +/// BlockFrequencyInfo, TargetLibraryInfo, Loop, AliasSet information for all +/// instructions of the loop and loop safety information as arguments. +/// Diagnostics is emitted via \p ORE. It returns changed status. bool hoistRegion(DomTreeNode *, AAResults *, LoopInfo *, DominatorTree *, - BlockFrequencyInfo *, TargetLibraryInfo *, Loop *, - AliasSetTracker *, MemorySSAUpdater *, ScalarEvolution *, - ICFLoopSafetyInfo *, SinkAndHoistLICMFlags &, - OptimizationRemarkEmitter *); + BlockFrequencyInfo *, TargetLibraryInfo *, Loop *, + AliasSetTracker *, MemorySSAUpdater *, ScalarEvolution *, + ICFLoopSafetyInfo *, SinkAndHoistLICMFlags &, + OptimizationRemarkEmitter *); /// This function deletes dead loops. The caller of this function needs to /// guarantee that the loop is infact dead. @@ -187,12 +187,12 @@ bool hoistRegion(DomTreeNode *, AAResults *, LoopInfo *, DominatorTree *, void deleteDeadLoop(Loop *L, DominatorTree *DT, ScalarEvolution *SE, LoopInfo *LI, MemorySSA *MSSA = nullptr); -/// Remove the backedge of the specified loop. Handles loop nests and general -/// loop structures subject to the precondition that the loop has no parent -/// loop and has a single latch block. Preserves all listed analyses. -void breakLoopBackedge(Loop *L, DominatorTree &DT, ScalarEvolution &SE, - LoopInfo &LI, MemorySSA *MSSA); - +/// Remove the backedge of the specified loop. Handles loop nests and general +/// loop structures subject to the precondition that the loop has no parent +/// loop and has a single latch block. Preserves all listed analyses. +void breakLoopBackedge(Loop *L, DominatorTree &DT, ScalarEvolution &SE, + LoopInfo &LI, MemorySSA *MSSA); + /// Try to promote memory values to scalars by sinking stores out of /// the loop and moving loads to before the loop. We do this by looping over /// the stores in the loop, looking for stores to Must pointers which are @@ -227,13 +227,13 @@ Optional<const MDOperand *> findStringMetadataForLoop(const Loop *TheLoop, /// Find named metadata for a loop with an integer value. llvm::Optional<int> getOptionalIntLoopAttribute(Loop *TheLoop, StringRef Name); -/// Find a combination of metadata ("llvm.loop.vectorize.width" and -/// "llvm.loop.vectorize.scalable.enable") for a loop and use it to construct a -/// ElementCount. If the metadata "llvm.loop.vectorize.width" cannot be found -/// then None is returned. -Optional<ElementCount> -getOptionalElementCountLoopAttribute(Loop *TheLoop); - +/// Find a combination of metadata ("llvm.loop.vectorize.width" and +/// "llvm.loop.vectorize.scalable.enable") for a loop and use it to construct a +/// ElementCount. If the metadata "llvm.loop.vectorize.width" cannot be found +/// then None is returned. +Optional<ElementCount> +getOptionalElementCountLoopAttribute(Loop *TheLoop); + /// Create a new loop identifier for a loop created from a loop transformation. /// /// @param OrigLoopID The loop ID of the loop before the transformation. @@ -269,9 +269,9 @@ bool hasDisableAllTransformsHint(const Loop *L); /// Look for the loop attribute that disables the LICM transformation heuristics. bool hasDisableLICMTransformsHint(const Loop *L); -/// Look for the loop attribute that requires progress within the loop. -bool hasMustProgress(const Loop *L); - +/// Look for the loop attribute that requires progress within the loop. +bool hasMustProgress(const Loop *L); + /// The mode sets how eager a transformation should be applied. enum TransformationMode { /// The pass can use heuristics to determine whether a transformation should @@ -314,9 +314,9 @@ TransformationMode hasLICMVersioningTransformation(Loop *L); void addStringMetadataToLoop(Loop *TheLoop, const char *MDString, unsigned V = 0); -/// Returns true if Name is applied to TheLoop and enabled. -bool getBooleanLoopAttribute(const Loop *TheLoop, StringRef Name); - +/// Returns true if Name is applied to TheLoop and enabled. +bool getBooleanLoopAttribute(const Loop *TheLoop, StringRef Name); + /// Returns a loop's estimated trip count based on branch weight metadata. /// In addition if \p EstimatedLoopInvocationWeight is not null it is /// initialized with weight of loop's latch leading to the exit. @@ -362,29 +362,29 @@ bool canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT, OptimizationRemarkEmitter *ORE = nullptr); /// Returns a Min/Max operation corresponding to MinMaxRecurrenceKind. -Value *createMinMaxOp(IRBuilderBase &Builder, RecurKind RK, Value *Left, - Value *Right); +Value *createMinMaxOp(IRBuilderBase &Builder, RecurKind RK, Value *Left, + Value *Right); /// Generates an ordered vector reduction using extracts to reduce the value. -Value *getOrderedReduction(IRBuilderBase &Builder, Value *Acc, Value *Src, - unsigned Op, RecurKind MinMaxKind = RecurKind::None, - ArrayRef<Value *> RedOps = None); +Value *getOrderedReduction(IRBuilderBase &Builder, Value *Acc, Value *Src, + unsigned Op, RecurKind MinMaxKind = RecurKind::None, + ArrayRef<Value *> RedOps = None); /// Generates a vector reduction using shufflevectors to reduce the value. /// Fast-math-flags are propagated using the IRBuilder's setting. Value *getShuffleReduction(IRBuilderBase &Builder, Value *Src, unsigned Op, - RecurKind MinMaxKind = RecurKind::None, + RecurKind MinMaxKind = RecurKind::None, ArrayRef<Value *> RedOps = None); /// Create a target reduction of the given vector. The reduction operation /// is described by the \p Opcode parameter. min/max reductions require -/// additional information supplied in \p RdxKind. +/// additional information supplied in \p RdxKind. /// The target is queried to determine if intrinsics or shuffle sequences are /// required to implement the reduction. /// Fast-math-flags are propagated using the IRBuilder's setting. Value *createSimpleTargetReduction(IRBuilderBase &B, - const TargetTransformInfo *TTI, Value *Src, - RecurKind RdxKind, + const TargetTransformInfo *TTI, Value *Src, + RecurKind RdxKind, ArrayRef<Value *> RedOps = None); /// Create a generic target reduction using a recurrence descriptor \p Desc @@ -392,7 +392,7 @@ Value *createSimpleTargetReduction(IRBuilderBase &B, /// required to implement the reduction. /// Fast-math-flags are propagated using the RecurrenceDescriptor. Value *createTargetReduction(IRBuilderBase &B, const TargetTransformInfo *TTI, - RecurrenceDescriptor &Desc, Value *Src); + RecurrenceDescriptor &Desc, Value *Src); /// Get the intersection (logical and) of all of the potential IR flags /// of each scalar operation (VL) that will be converted into a vector (I). diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopVersioning.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopVersioning.h index dd7394a3f0..fb33ce142b 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopVersioning.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/LoopVersioning.h @@ -23,7 +23,7 @@ #define LLVM_TRANSFORMS_UTILS_LOOPVERSIONING_H #include "llvm/Analysis/ScalarEvolution.h" -#include "llvm/IR/PassManager.h" +#include "llvm/IR/PassManager.h" #include "llvm/Transforms/Utils/LoopUtils.h" #include "llvm/Transforms/Utils/ValueMapper.h" @@ -50,9 +50,9 @@ public: /// It uses runtime check provided by the user. If \p UseLAIChecks is true, /// we will retain the default checks made by LAI. Otherwise, construct an /// object having no checks and we expect the user to add them. - LoopVersioning(const LoopAccessInfo &LAI, - ArrayRef<RuntimePointerCheck> Checks, Loop *L, LoopInfo *LI, - DominatorTree *DT, ScalarEvolution *SE); + LoopVersioning(const LoopAccessInfo &LAI, + ArrayRef<RuntimePointerCheck> Checks, Loop *L, LoopInfo *LI, + DominatorTree *DT, ScalarEvolution *SE); /// Performs the CFG manipulation part of versioning the loop including /// the DominatorTree and LoopInfo updates. @@ -130,7 +130,7 @@ private: SmallVector<RuntimePointerCheck, 4> AliasChecks; /// The set of SCEV checks that we are versioning for. - const SCEVUnionPredicate &Preds; + const SCEVUnionPredicate &Preds; /// Maps a pointer to the pointer checking group that the pointer /// belongs to. @@ -149,14 +149,14 @@ private: DominatorTree *DT; ScalarEvolution *SE; }; - -/// Expose LoopVersioning as a pass. Currently this is only used for -/// unit-testing. It adds all memchecks necessary to remove all may-aliasing -/// array accesses from the loop. -class LoopVersioningPass : public PassInfoMixin<LoopVersioningPass> { -public: - PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM); -}; + +/// Expose LoopVersioning as a pass. Currently this is only used for +/// unit-testing. It adds all memchecks necessary to remove all may-aliasing +/// array accesses from the loop. +class LoopVersioningPass : public PassInfoMixin<LoopVersioningPass> { +public: + PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM); +}; } #endif diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/LowerSwitch.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/LowerSwitch.h index 1d177dd618..5a801fc704 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/LowerSwitch.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/LowerSwitch.h @@ -1,37 +1,37 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- LowerSwitch.h - Eliminate Switch instructions ----------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// The LowerSwitch transformation rewrites switch instructions with a sequence -// of branches, which allows targets to get away with not implementing the -// switch instruction until it is convenient. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TRANSFORMS_UTILS_LOWERSWITCH_H -#define LLVM_TRANSFORMS_UTILS_LOWERSWITCH_H - -#include "llvm/IR/PassManager.h" - -namespace llvm { -struct LowerSwitchPass : public PassInfoMixin<LowerSwitchPass> { - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); -}; -} // namespace llvm - -#endif // LLVM_TRANSFORMS_UTILS_LOWERSWITCH_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- LowerSwitch.h - Eliminate Switch instructions ----------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// The LowerSwitch transformation rewrites switch instructions with a sequence +// of branches, which allows targets to get away with not implementing the +// switch instruction until it is convenient. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_TRANSFORMS_UTILS_LOWERSWITCH_H +#define LLVM_TRANSFORMS_UTILS_LOWERSWITCH_H + +#include "llvm/IR/PassManager.h" + +namespace llvm { +struct LowerSwitchPass : public PassInfoMixin<LowerSwitchPass> { + PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); +}; +} // namespace llvm + +#endif // LLVM_TRANSFORMS_UTILS_LOWERSWITCH_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/MatrixUtils.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/MatrixUtils.h index 948e51e22b..8606974e57 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/MatrixUtils.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/MatrixUtils.h @@ -1,105 +1,105 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- MatrixUtils.h - Utilities to lower matrix intrinsics -----*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// Utilities for generating tiled loops for matrix operations. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TRANSFORMS_UTILS_MATRIXUTILS_H -#define LLVM_TRANSFORMS_UTILS_MATRIXUTILS_H - -#include "llvm/ADT/StringRef.h" - -namespace llvm { -class DomTreeUpdater; -class BasicBlock; -class Value; -class Loop; -class LoopInfo; -class IRBuilderBase; - -/// A helper struct to create IR loop nests for tiling in IR of the following -/// form: -/// for CurrentColumn = 0..NumColumns -/// for CurrentRow = 0..NumRows -/// for CurrentInner = 0..NumInner -struct TileInfo { - /// Number of rows of the matrix. - unsigned NumRows; - - /// Number of columns of the matrix. - unsigned NumColumns; - - /// Number of columns of the first matrix of a multiply / - /// number of rows of the second matrix of a multiply. - unsigned NumInner; - - /// Number of rows/columns in a tile. - unsigned TileSize = -1; - - /// Start row of the current tile to compute. - Value *CurrentRow; - - /// Start column of the current tile to compute. - Value *CurrentCol; - - /// Current tile offset during the tile computation. - Value *CurrentK; - - /// Header of the outermost loop iterating from 0..NumColumns. - BasicBlock *ColumnLoopHeader = nullptr; - - /// Header of the second loop iterating from 0..NumRows. - BasicBlock *RowLoopHeader = nullptr; - /// Latch of the second loop iterating from 0..NumRows. - BasicBlock *RowLoopLatch = nullptr; - /// Header of the innermost loop iterating from 0..NumInner. - BasicBlock *InnerLoopHeader = nullptr; - /// Latch of the innermost loop iterating from 0..NumInner. - BasicBlock *InnerLoopLatch = nullptr; - - TileInfo(unsigned NumRows, unsigned NumColumns, unsigned NumInner, - unsigned TileSize) - : NumRows(NumRows), NumColumns(NumColumns), NumInner(NumInner), - TileSize(TileSize) {} - - /// Creates an IR loop nests for tiling of the form below. Returns the block - /// for the inner loop body and sets {Column,Row,Inner}LoopHeader/Latch - /// fields. - /// - /// for CurrentColumn = 0..NumColumns - /// for CurrentRow = 0..NumRows - /// for CurrentInner = 0..NumInner - BasicBlock *CreateTiledLoops(BasicBlock *Start, BasicBlock *End, - IRBuilderBase &B, DomTreeUpdater &DTU, - LoopInfo &LI); - -private: - /// Creates a new loop with header, body and latch blocks that iterates from - /// [0, Bound). Updates \p Preheader to branch to the new header and uses \p - /// Exit as exit block. Adds the new loop blocks to \L and applies dominator - /// tree updates to \p DTU. - static BasicBlock *CreateLoop(BasicBlock *Preheader, BasicBlock *Exit, - Value *Bound, Value *Step, StringRef Name, - IRBuilderBase &B, DomTreeUpdater &DTU, Loop *L, - LoopInfo &LI); -}; -} // namespace llvm - -#endif - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- MatrixUtils.h - Utilities to lower matrix intrinsics -----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Utilities for generating tiled loops for matrix operations. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_TRANSFORMS_UTILS_MATRIXUTILS_H +#define LLVM_TRANSFORMS_UTILS_MATRIXUTILS_H + +#include "llvm/ADT/StringRef.h" + +namespace llvm { +class DomTreeUpdater; +class BasicBlock; +class Value; +class Loop; +class LoopInfo; +class IRBuilderBase; + +/// A helper struct to create IR loop nests for tiling in IR of the following +/// form: +/// for CurrentColumn = 0..NumColumns +/// for CurrentRow = 0..NumRows +/// for CurrentInner = 0..NumInner +struct TileInfo { + /// Number of rows of the matrix. + unsigned NumRows; + + /// Number of columns of the matrix. + unsigned NumColumns; + + /// Number of columns of the first matrix of a multiply / + /// number of rows of the second matrix of a multiply. + unsigned NumInner; + + /// Number of rows/columns in a tile. + unsigned TileSize = -1; + + /// Start row of the current tile to compute. + Value *CurrentRow; + + /// Start column of the current tile to compute. + Value *CurrentCol; + + /// Current tile offset during the tile computation. + Value *CurrentK; + + /// Header of the outermost loop iterating from 0..NumColumns. + BasicBlock *ColumnLoopHeader = nullptr; + + /// Header of the second loop iterating from 0..NumRows. + BasicBlock *RowLoopHeader = nullptr; + /// Latch of the second loop iterating from 0..NumRows. + BasicBlock *RowLoopLatch = nullptr; + /// Header of the innermost loop iterating from 0..NumInner. + BasicBlock *InnerLoopHeader = nullptr; + /// Latch of the innermost loop iterating from 0..NumInner. + BasicBlock *InnerLoopLatch = nullptr; + + TileInfo(unsigned NumRows, unsigned NumColumns, unsigned NumInner, + unsigned TileSize) + : NumRows(NumRows), NumColumns(NumColumns), NumInner(NumInner), + TileSize(TileSize) {} + + /// Creates an IR loop nests for tiling of the form below. Returns the block + /// for the inner loop body and sets {Column,Row,Inner}LoopHeader/Latch + /// fields. + /// + /// for CurrentColumn = 0..NumColumns + /// for CurrentRow = 0..NumRows + /// for CurrentInner = 0..NumInner + BasicBlock *CreateTiledLoops(BasicBlock *Start, BasicBlock *End, + IRBuilderBase &B, DomTreeUpdater &DTU, + LoopInfo &LI); + +private: + /// Creates a new loop with header, body and latch blocks that iterates from + /// [0, Bound). Updates \p Preheader to branch to the new header and uses \p + /// Exit as exit block. Adds the new loop blocks to \L and applies dominator + /// tree updates to \p DTU. + static BasicBlock *CreateLoop(BasicBlock *Preheader, BasicBlock *Exit, + Value *Bound, Value *Step, StringRef Name, + IRBuilderBase &B, DomTreeUpdater &DTU, Loop *L, + LoopInfo &LI); +}; +} // namespace llvm + +#endif + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/MetaRenamer.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/MetaRenamer.h index f7aab0a1c5..1e90f7590f 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/MetaRenamer.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/MetaRenamer.h @@ -1,37 +1,37 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- MetaRenamer.h - Rename everything with metasyntatic names ----------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This pass renames everything with metasyntatic names. The intent is to use -// this pass after bugpoint reduction to conceal the nature of the original -// program. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TRANSFORMS_UTILS_METARENAMER_H -#define LLVM_TRANSFORMS_UTILS_METARENAMER_H - -#include "llvm/IR/PassManager.h" - -namespace llvm { -struct MetaRenamerPass : PassInfoMixin<MetaRenamerPass> { - PreservedAnalyses run(Module &, ModuleAnalysisManager &); -}; -} // namespace llvm - -#endif // LLVM_TRANSFORMS_UTILS_METARENAMER_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- MetaRenamer.h - Rename everything with metasyntatic names ----------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This pass renames everything with metasyntatic names. The intent is to use +// this pass after bugpoint reduction to conceal the nature of the original +// program. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_TRANSFORMS_UTILS_METARENAMER_H +#define LLVM_TRANSFORMS_UTILS_METARENAMER_H + +#include "llvm/IR/PassManager.h" + +namespace llvm { +struct MetaRenamerPass : PassInfoMixin<MetaRenamerPass> { + PreservedAnalyses run(Module &, ModuleAnalysisManager &); +}; +} // namespace llvm + +#endif // LLVM_TRANSFORMS_UTILS_METARENAMER_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/PredicateInfo.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/PredicateInfo.h index ced45bb3bd..628696ecb0 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/PredicateInfo.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/PredicateInfo.h @@ -77,13 +77,13 @@ class raw_ostream; enum PredicateType { PT_Branch, PT_Assume, PT_Switch }; -/// Constraint for a predicate of the form "cmp Pred Op, OtherOp", where Op -/// is the value the constraint applies to (the ssa.copy result). -struct PredicateConstraint { - CmpInst::Predicate Predicate; - Value *OtherOp; -}; - +/// Constraint for a predicate of the form "cmp Pred Op, OtherOp", where Op +/// is the value the constraint applies to (the ssa.copy result). +struct PredicateConstraint { + CmpInst::Predicate Predicate; + Value *OtherOp; +}; + // Base class for all predicate information we provide. // All of our predicate information has at least a comparison. class PredicateBase : public ilist_node<PredicateBase> { @@ -97,9 +97,9 @@ public: // predicates, this is different to OriginalOp which refers to the initial // operand. Value *RenamedOp; - // The condition associated with this predicate. - Value *Condition; - + // The condition associated with this predicate. + Value *Condition; + PredicateBase(const PredicateBase &) = delete; PredicateBase &operator=(const PredicateBase &) = delete; PredicateBase() = delete; @@ -109,22 +109,22 @@ public: PB->Type == PT_Switch; } - /// Fetch condition in the form of PredicateConstraint, if possible. - Optional<PredicateConstraint> getConstraint() const; - + /// Fetch condition in the form of PredicateConstraint, if possible. + Optional<PredicateConstraint> getConstraint() const; + protected: - PredicateBase(PredicateType PT, Value *Op, Value *Condition) - : Type(PT), OriginalOp(Op), Condition(Condition) {} + PredicateBase(PredicateType PT, Value *Op, Value *Condition) + : Type(PT), OriginalOp(Op), Condition(Condition) {} }; // Provides predicate information for assumes. Since assumes are always true, // we simply provide the assume instruction, so you can tell your relative // position to it. -class PredicateAssume : public PredicateBase { +class PredicateAssume : public PredicateBase { public: IntrinsicInst *AssumeInst; PredicateAssume(Value *Op, IntrinsicInst *AssumeInst, Value *Condition) - : PredicateBase(PT_Assume, Op, Condition), AssumeInst(AssumeInst) {} + : PredicateBase(PT_Assume, Op, Condition), AssumeInst(AssumeInst) {} PredicateAssume() = delete; static bool classof(const PredicateBase *PB) { return PB->Type == PT_Assume; @@ -134,7 +134,7 @@ public: // Mixin class for edge predicates. The FROM block is the block where the // predicate originates, and the TO block is the block where the predicate is // valid. -class PredicateWithEdge : public PredicateBase { +class PredicateWithEdge : public PredicateBase { public: BasicBlock *From; BasicBlock *To; @@ -146,7 +146,7 @@ public: protected: PredicateWithEdge(PredicateType PType, Value *Op, BasicBlock *From, BasicBlock *To, Value *Cond) - : PredicateBase(PType, Op, Cond), From(From), To(To) {} + : PredicateBase(PType, Op, Cond), From(From), To(To) {} }; // Provides predicate information for branches. diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h index 02e8cf94ba..d1f41d91a0 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h @@ -33,488 +33,488 @@ #include "llvm/Support/CommandLine.h" namespace llvm { -extern cl::opt<unsigned> SCEVCheapExpansionBudget; - -/// Return true if the given expression is safe to expand in the sense that -/// all materialized values are safe to speculate anywhere their operands are -/// defined. -bool isSafeToExpand(const SCEV *S, ScalarEvolution &SE); - -/// Return true if the given expression is safe to expand in the sense that -/// all materialized values are defined and safe to speculate at the specified -/// location and their operands are defined at this location. -bool isSafeToExpandAt(const SCEV *S, const Instruction *InsertionPoint, - ScalarEvolution &SE); - -/// struct for holding enough information to help calculate the cost of the -/// given SCEV when expanded into IR. -struct SCEVOperand { - explicit SCEVOperand(unsigned Opc, int Idx, const SCEV *S) : - ParentOpcode(Opc), OperandIdx(Idx), S(S) { } - /// LLVM instruction opcode that uses the operand. - unsigned ParentOpcode; - /// The use index of an expanded instruction. - int OperandIdx; - /// The SCEV operand to be costed. - const SCEV* S; -}; - -/// This class uses information about analyze scalars to rewrite expressions -/// in canonical form. -/// -/// Clients should create an instance of this class when rewriting is needed, -/// and destroy it when finished to allow the release of the associated -/// memory. -class SCEVExpander : public SCEVVisitor<SCEVExpander, Value *> { - ScalarEvolution &SE; - const DataLayout &DL; - - // New instructions receive a name to identify them with the current pass. - const char *IVName; - - /// Indicates whether LCSSA phis should be created for inserted values. - bool PreserveLCSSA; - - // InsertedExpressions caches Values for reuse, so must track RAUW. - DenseMap<std::pair<const SCEV *, Instruction *>, TrackingVH<Value>> - InsertedExpressions; - - // InsertedValues only flags inserted instructions so needs no RAUW. - DenseSet<AssertingVH<Value>> InsertedValues; - DenseSet<AssertingVH<Value>> InsertedPostIncValues; - - /// Keep track of the existing IR values re-used during expansion. - /// FIXME: Ideally re-used instructions would not be added to - /// InsertedValues/InsertedPostIncValues. - SmallPtrSet<Value *, 16> ReusedValues; - - /// A memoization of the "relevant" loop for a given SCEV. - DenseMap<const SCEV *, const Loop *> RelevantLoops; - - /// Addrecs referring to any of the given loops are expanded in post-inc - /// mode. For example, expanding {1,+,1}<L> in post-inc mode returns the add - /// instruction that adds one to the phi for {0,+,1}<L>, as opposed to a new - /// phi starting at 1. This is only supported in non-canonical mode. - PostIncLoopSet PostIncLoops; - - /// When this is non-null, addrecs expanded in the loop it indicates should - /// be inserted with increments at IVIncInsertPos. - const Loop *IVIncInsertLoop; - - /// When expanding addrecs in the IVIncInsertLoop loop, insert the IV - /// increment at this position. - Instruction *IVIncInsertPos; - - /// Phis that complete an IV chain. Reuse - DenseSet<AssertingVH<PHINode>> ChainedPhis; - - /// When true, SCEVExpander tries to expand expressions in "canonical" form. - /// When false, expressions are expanded in a more literal form. - /// - /// In "canonical" form addrecs are expanded as arithmetic based on a - /// canonical induction variable. Note that CanonicalMode doesn't guarantee - /// that all expressions are expanded in "canonical" form. For some - /// expressions literal mode can be preferred. - bool CanonicalMode; - - /// When invoked from LSR, the expander is in "strength reduction" mode. The - /// only difference is that phi's are only reused if they are already in - /// "expanded" form. - bool LSRMode; - - typedef IRBuilder<TargetFolder, IRBuilderCallbackInserter> BuilderType; - BuilderType Builder; - - // RAII object that stores the current insertion point and restores it when - // the object is destroyed. This includes the debug location. Duplicated - // from InsertPointGuard to add SetInsertPoint() which is used to updated - // InsertPointGuards stack when insert points are moved during SCEV - // expansion. - class SCEVInsertPointGuard { - IRBuilderBase &Builder; - AssertingVH<BasicBlock> Block; - BasicBlock::iterator Point; - DebugLoc DbgLoc; - SCEVExpander *SE; - - SCEVInsertPointGuard(const SCEVInsertPointGuard &) = delete; - SCEVInsertPointGuard &operator=(const SCEVInsertPointGuard &) = delete; - - public: - SCEVInsertPointGuard(IRBuilderBase &B, SCEVExpander *SE) - : Builder(B), Block(B.GetInsertBlock()), Point(B.GetInsertPoint()), - DbgLoc(B.getCurrentDebugLocation()), SE(SE) { - SE->InsertPointGuards.push_back(this); - } - - ~SCEVInsertPointGuard() { - // These guards should always created/destroyed in FIFO order since they - // are used to guard lexically scoped blocks of code in - // ScalarEvolutionExpander. - assert(SE->InsertPointGuards.back() == this); - SE->InsertPointGuards.pop_back(); - Builder.restoreIP(IRBuilderBase::InsertPoint(Block, Point)); - Builder.SetCurrentDebugLocation(DbgLoc); - } - - BasicBlock::iterator GetInsertPoint() const { return Point; } - void SetInsertPoint(BasicBlock::iterator I) { Point = I; } - }; - - /// Stack of pointers to saved insert points, used to keep insert points - /// consistent when instructions are moved. - SmallVector<SCEVInsertPointGuard *, 8> InsertPointGuards; - +extern cl::opt<unsigned> SCEVCheapExpansionBudget; + +/// Return true if the given expression is safe to expand in the sense that +/// all materialized values are safe to speculate anywhere their operands are +/// defined. +bool isSafeToExpand(const SCEV *S, ScalarEvolution &SE); + +/// Return true if the given expression is safe to expand in the sense that +/// all materialized values are defined and safe to speculate at the specified +/// location and their operands are defined at this location. +bool isSafeToExpandAt(const SCEV *S, const Instruction *InsertionPoint, + ScalarEvolution &SE); + +/// struct for holding enough information to help calculate the cost of the +/// given SCEV when expanded into IR. +struct SCEVOperand { + explicit SCEVOperand(unsigned Opc, int Idx, const SCEV *S) : + ParentOpcode(Opc), OperandIdx(Idx), S(S) { } + /// LLVM instruction opcode that uses the operand. + unsigned ParentOpcode; + /// The use index of an expanded instruction. + int OperandIdx; + /// The SCEV operand to be costed. + const SCEV* S; +}; + +/// This class uses information about analyze scalars to rewrite expressions +/// in canonical form. +/// +/// Clients should create an instance of this class when rewriting is needed, +/// and destroy it when finished to allow the release of the associated +/// memory. +class SCEVExpander : public SCEVVisitor<SCEVExpander, Value *> { + ScalarEvolution &SE; + const DataLayout &DL; + + // New instructions receive a name to identify them with the current pass. + const char *IVName; + + /// Indicates whether LCSSA phis should be created for inserted values. + bool PreserveLCSSA; + + // InsertedExpressions caches Values for reuse, so must track RAUW. + DenseMap<std::pair<const SCEV *, Instruction *>, TrackingVH<Value>> + InsertedExpressions; + + // InsertedValues only flags inserted instructions so needs no RAUW. + DenseSet<AssertingVH<Value>> InsertedValues; + DenseSet<AssertingVH<Value>> InsertedPostIncValues; + + /// Keep track of the existing IR values re-used during expansion. + /// FIXME: Ideally re-used instructions would not be added to + /// InsertedValues/InsertedPostIncValues. + SmallPtrSet<Value *, 16> ReusedValues; + + /// A memoization of the "relevant" loop for a given SCEV. + DenseMap<const SCEV *, const Loop *> RelevantLoops; + + /// Addrecs referring to any of the given loops are expanded in post-inc + /// mode. For example, expanding {1,+,1}<L> in post-inc mode returns the add + /// instruction that adds one to the phi for {0,+,1}<L>, as opposed to a new + /// phi starting at 1. This is only supported in non-canonical mode. + PostIncLoopSet PostIncLoops; + + /// When this is non-null, addrecs expanded in the loop it indicates should + /// be inserted with increments at IVIncInsertPos. + const Loop *IVIncInsertLoop; + + /// When expanding addrecs in the IVIncInsertLoop loop, insert the IV + /// increment at this position. + Instruction *IVIncInsertPos; + + /// Phis that complete an IV chain. Reuse + DenseSet<AssertingVH<PHINode>> ChainedPhis; + + /// When true, SCEVExpander tries to expand expressions in "canonical" form. + /// When false, expressions are expanded in a more literal form. + /// + /// In "canonical" form addrecs are expanded as arithmetic based on a + /// canonical induction variable. Note that CanonicalMode doesn't guarantee + /// that all expressions are expanded in "canonical" form. For some + /// expressions literal mode can be preferred. + bool CanonicalMode; + + /// When invoked from LSR, the expander is in "strength reduction" mode. The + /// only difference is that phi's are only reused if they are already in + /// "expanded" form. + bool LSRMode; + + typedef IRBuilder<TargetFolder, IRBuilderCallbackInserter> BuilderType; + BuilderType Builder; + + // RAII object that stores the current insertion point and restores it when + // the object is destroyed. This includes the debug location. Duplicated + // from InsertPointGuard to add SetInsertPoint() which is used to updated + // InsertPointGuards stack when insert points are moved during SCEV + // expansion. + class SCEVInsertPointGuard { + IRBuilderBase &Builder; + AssertingVH<BasicBlock> Block; + BasicBlock::iterator Point; + DebugLoc DbgLoc; + SCEVExpander *SE; + + SCEVInsertPointGuard(const SCEVInsertPointGuard &) = delete; + SCEVInsertPointGuard &operator=(const SCEVInsertPointGuard &) = delete; + + public: + SCEVInsertPointGuard(IRBuilderBase &B, SCEVExpander *SE) + : Builder(B), Block(B.GetInsertBlock()), Point(B.GetInsertPoint()), + DbgLoc(B.getCurrentDebugLocation()), SE(SE) { + SE->InsertPointGuards.push_back(this); + } + + ~SCEVInsertPointGuard() { + // These guards should always created/destroyed in FIFO order since they + // are used to guard lexically scoped blocks of code in + // ScalarEvolutionExpander. + assert(SE->InsertPointGuards.back() == this); + SE->InsertPointGuards.pop_back(); + Builder.restoreIP(IRBuilderBase::InsertPoint(Block, Point)); + Builder.SetCurrentDebugLocation(DbgLoc); + } + + BasicBlock::iterator GetInsertPoint() const { return Point; } + void SetInsertPoint(BasicBlock::iterator I) { Point = I; } + }; + + /// Stack of pointers to saved insert points, used to keep insert points + /// consistent when instructions are moved. + SmallVector<SCEVInsertPointGuard *, 8> InsertPointGuards; + #ifndef NDEBUG - const char *DebugType; + const char *DebugType; #endif - friend struct SCEVVisitor<SCEVExpander, Value *>; - -public: - /// Construct a SCEVExpander in "canonical" mode. - explicit SCEVExpander(ScalarEvolution &se, const DataLayout &DL, - const char *name, bool PreserveLCSSA = true) - : SE(se), DL(DL), IVName(name), PreserveLCSSA(PreserveLCSSA), - IVIncInsertLoop(nullptr), IVIncInsertPos(nullptr), CanonicalMode(true), - LSRMode(false), - Builder(se.getContext(), TargetFolder(DL), - IRBuilderCallbackInserter( - [this](Instruction *I) { rememberInstruction(I); })) { + friend struct SCEVVisitor<SCEVExpander, Value *>; + +public: + /// Construct a SCEVExpander in "canonical" mode. + explicit SCEVExpander(ScalarEvolution &se, const DataLayout &DL, + const char *name, bool PreserveLCSSA = true) + : SE(se), DL(DL), IVName(name), PreserveLCSSA(PreserveLCSSA), + IVIncInsertLoop(nullptr), IVIncInsertPos(nullptr), CanonicalMode(true), + LSRMode(false), + Builder(se.getContext(), TargetFolder(DL), + IRBuilderCallbackInserter( + [this](Instruction *I) { rememberInstruction(I); })) { #ifndef NDEBUG - DebugType = ""; + DebugType = ""; #endif - } + } - ~SCEVExpander() { - // Make sure the insert point guard stack is consistent. - assert(InsertPointGuards.empty()); - } + ~SCEVExpander() { + // Make sure the insert point guard stack is consistent. + assert(InsertPointGuards.empty()); + } #ifndef NDEBUG - void setDebugType(const char *s) { DebugType = s; } + void setDebugType(const char *s) { DebugType = s; } #endif - /// Erase the contents of the InsertedExpressions map so that users trying - /// to expand the same expression into multiple BasicBlocks or different - /// places within the same BasicBlock can do so. - void clear() { - InsertedExpressions.clear(); - InsertedValues.clear(); - InsertedPostIncValues.clear(); - ReusedValues.clear(); - ChainedPhis.clear(); - } - - /// Return a vector containing all instructions inserted during expansion. - SmallVector<Instruction *, 32> getAllInsertedInstructions() const { - SmallVector<Instruction *, 32> Result; - for (auto &VH : InsertedValues) { - Value *V = VH; - if (ReusedValues.contains(V)) - continue; - if (auto *Inst = dyn_cast<Instruction>(V)) - Result.push_back(Inst); + /// Erase the contents of the InsertedExpressions map so that users trying + /// to expand the same expression into multiple BasicBlocks or different + /// places within the same BasicBlock can do so. + void clear() { + InsertedExpressions.clear(); + InsertedValues.clear(); + InsertedPostIncValues.clear(); + ReusedValues.clear(); + ChainedPhis.clear(); + } + + /// Return a vector containing all instructions inserted during expansion. + SmallVector<Instruction *, 32> getAllInsertedInstructions() const { + SmallVector<Instruction *, 32> Result; + for (auto &VH : InsertedValues) { + Value *V = VH; + if (ReusedValues.contains(V)) + continue; + if (auto *Inst = dyn_cast<Instruction>(V)) + Result.push_back(Inst); } - for (auto &VH : InsertedPostIncValues) { - Value *V = VH; - if (ReusedValues.contains(V)) - continue; - if (auto *Inst = dyn_cast<Instruction>(V)) - Result.push_back(Inst); + for (auto &VH : InsertedPostIncValues) { + Value *V = VH; + if (ReusedValues.contains(V)) + continue; + if (auto *Inst = dyn_cast<Instruction>(V)) + Result.push_back(Inst); + } + + return Result; + } + + /// Return true for expressions that can't be evaluated at runtime + /// within given \b Budget. + /// + /// At is a parameter which specifies point in code where user is going to + /// expand this expression. Sometimes this knowledge can lead to + /// a less pessimistic cost estimation. + bool isHighCostExpansion(const SCEV *Expr, Loop *L, unsigned Budget, + const TargetTransformInfo *TTI, + const Instruction *At) { + assert(TTI && "This function requires TTI to be provided."); + assert(At && "This function requires At instruction to be provided."); + if (!TTI) // In assert-less builds, avoid crashing + return true; // by always claiming to be high-cost. + SmallVector<SCEVOperand, 8> Worklist; + SmallPtrSet<const SCEV *, 8> Processed; + int BudgetRemaining = Budget * TargetTransformInfo::TCC_Basic; + Worklist.emplace_back(-1, -1, Expr); + while (!Worklist.empty()) { + const SCEVOperand WorkItem = Worklist.pop_back_val(); + if (isHighCostExpansionHelper(WorkItem, L, *At, BudgetRemaining, + *TTI, Processed, Worklist)) + return true; } - - return Result; - } - - /// Return true for expressions that can't be evaluated at runtime - /// within given \b Budget. - /// - /// At is a parameter which specifies point in code where user is going to - /// expand this expression. Sometimes this knowledge can lead to - /// a less pessimistic cost estimation. - bool isHighCostExpansion(const SCEV *Expr, Loop *L, unsigned Budget, - const TargetTransformInfo *TTI, - const Instruction *At) { - assert(TTI && "This function requires TTI to be provided."); - assert(At && "This function requires At instruction to be provided."); - if (!TTI) // In assert-less builds, avoid crashing - return true; // by always claiming to be high-cost. - SmallVector<SCEVOperand, 8> Worklist; - SmallPtrSet<const SCEV *, 8> Processed; - int BudgetRemaining = Budget * TargetTransformInfo::TCC_Basic; - Worklist.emplace_back(-1, -1, Expr); - while (!Worklist.empty()) { - const SCEVOperand WorkItem = Worklist.pop_back_val(); - if (isHighCostExpansionHelper(WorkItem, L, *At, BudgetRemaining, - *TTI, Processed, Worklist)) - return true; - } - assert(BudgetRemaining >= 0 && "Should have returned from inner loop."); - return false; - } - - /// Return the induction variable increment's IV operand. - Instruction *getIVIncOperand(Instruction *IncV, Instruction *InsertPos, - bool allowScale); - - /// Utility for hoisting an IV increment. - bool hoistIVInc(Instruction *IncV, Instruction *InsertPos); - - /// replace congruent phis with their most canonical representative. Return - /// the number of phis eliminated. - unsigned replaceCongruentIVs(Loop *L, const DominatorTree *DT, - SmallVectorImpl<WeakTrackingVH> &DeadInsts, - const TargetTransformInfo *TTI = nullptr); - - /// Insert code to directly compute the specified SCEV expression into the - /// program. The code is inserted into the specified block. - Value *expandCodeFor(const SCEV *SH, Type *Ty, Instruction *I) { - return expandCodeForImpl(SH, Ty, I, true); - } - - /// Insert code to directly compute the specified SCEV expression into the - /// program. The code is inserted into the SCEVExpander's current - /// insertion point. If a type is specified, the result will be expanded to - /// have that type, with a cast if necessary. - Value *expandCodeFor(const SCEV *SH, Type *Ty = nullptr) { - return expandCodeForImpl(SH, Ty, true); - } - - /// Generates a code sequence that evaluates this predicate. The inserted - /// instructions will be at position \p Loc. The result will be of type i1 - /// and will have a value of 0 when the predicate is false and 1 otherwise. - Value *expandCodeForPredicate(const SCEVPredicate *Pred, Instruction *Loc); - - /// A specialized variant of expandCodeForPredicate, handling the case when - /// we are expanding code for a SCEVEqualPredicate. - Value *expandEqualPredicate(const SCEVEqualPredicate *Pred, Instruction *Loc); - - /// Generates code that evaluates if the \p AR expression will overflow. - Value *generateOverflowCheck(const SCEVAddRecExpr *AR, Instruction *Loc, - bool Signed); - - /// A specialized variant of expandCodeForPredicate, handling the case when - /// we are expanding code for a SCEVWrapPredicate. - Value *expandWrapPredicate(const SCEVWrapPredicate *P, Instruction *Loc); - - /// A specialized variant of expandCodeForPredicate, handling the case when - /// we are expanding code for a SCEVUnionPredicate. - Value *expandUnionPredicate(const SCEVUnionPredicate *Pred, Instruction *Loc); - - /// Set the current IV increment loop and position. - void setIVIncInsertPos(const Loop *L, Instruction *Pos) { - assert(!CanonicalMode && - "IV increment positions are not supported in CanonicalMode"); - IVIncInsertLoop = L; - IVIncInsertPos = Pos; - } - - /// Enable post-inc expansion for addrecs referring to the given - /// loops. Post-inc expansion is only supported in non-canonical mode. - void setPostInc(const PostIncLoopSet &L) { - assert(!CanonicalMode && - "Post-inc expansion is not supported in CanonicalMode"); - PostIncLoops = L; - } - - /// Disable all post-inc expansion. - void clearPostInc() { - PostIncLoops.clear(); - - // When we change the post-inc loop set, cached expansions may no - // longer be valid. - InsertedPostIncValues.clear(); - } - - /// Disable the behavior of expanding expressions in canonical form rather - /// than in a more literal form. Non-canonical mode is useful for late - /// optimization passes. - void disableCanonicalMode() { CanonicalMode = false; } - - void enableLSRMode() { LSRMode = true; } - - /// Set the current insertion point. This is useful if multiple calls to - /// expandCodeFor() are going to be made with the same insert point and the - /// insert point may be moved during one of the expansions (e.g. if the - /// insert point is not a block terminator). - void setInsertPoint(Instruction *IP) { - assert(IP); - Builder.SetInsertPoint(IP); - } - - /// Clear the current insertion point. This is useful if the instruction - /// that had been serving as the insertion point may have been deleted. - void clearInsertPoint() { Builder.ClearInsertionPoint(); } - - /// Set location information used by debugging information. - void SetCurrentDebugLocation(DebugLoc L) { - Builder.SetCurrentDebugLocation(std::move(L)); - } - - /// Get location information used by debugging information. - DebugLoc getCurrentDebugLocation() const { - return Builder.getCurrentDebugLocation(); - } - - /// Return true if the specified instruction was inserted by the code - /// rewriter. If so, the client should not modify the instruction. Note that - /// this also includes instructions re-used during expansion. - bool isInsertedInstruction(Instruction *I) const { - return InsertedValues.count(I) || InsertedPostIncValues.count(I); - } - - void setChainedPhi(PHINode *PN) { ChainedPhis.insert(PN); } - - /// Try to find the ValueOffsetPair for S. The function is mainly used to - /// check whether S can be expanded cheaply. If this returns a non-None - /// value, we know we can codegen the `ValueOffsetPair` into a suitable - /// expansion identical with S so that S can be expanded cheaply. - /// - /// L is a hint which tells in which loop to look for the suitable value. - /// On success return value which is equivalent to the expanded S at point - /// At. Return nullptr if value was not found. - /// - /// Note that this function does not perform an exhaustive search. I.e if it - /// didn't find any value it does not mean that there is no such value. - /// - Optional<ScalarEvolution::ValueOffsetPair> - getRelatedExistingExpansion(const SCEV *S, const Instruction *At, Loop *L); - - /// Returns a suitable insert point after \p I, that dominates \p - /// MustDominate. Skips instructions inserted by the expander. - BasicBlock::iterator findInsertPointAfter(Instruction *I, - Instruction *MustDominate); - -private: - LLVMContext &getContext() const { return SE.getContext(); } - - /// Insert code to directly compute the specified SCEV expression into the - /// program. The code is inserted into the SCEVExpander's current - /// insertion point. If a type is specified, the result will be expanded to - /// have that type, with a cast if necessary. If \p Root is true, this - /// indicates that \p SH is the top-level expression to expand passed from - /// an external client call. - Value *expandCodeForImpl(const SCEV *SH, Type *Ty, bool Root); - - /// Insert code to directly compute the specified SCEV expression into the - /// program. The code is inserted into the specified block. If \p - /// Root is true, this indicates that \p SH is the top-level expression to - /// expand passed from an external client call. - Value *expandCodeForImpl(const SCEV *SH, Type *Ty, Instruction *I, bool Root); - - /// Recursive helper function for isHighCostExpansion. - bool isHighCostExpansionHelper( - const SCEVOperand &WorkItem, Loop *L, const Instruction &At, - int &BudgetRemaining, const TargetTransformInfo &TTI, - SmallPtrSetImpl<const SCEV *> &Processed, - SmallVectorImpl<SCEVOperand> &Worklist); - - /// Insert the specified binary operator, doing a small amount of work to - /// avoid inserting an obviously redundant operation, and hoisting to an - /// outer loop when the opportunity is there and it is safe. - Value *InsertBinop(Instruction::BinaryOps Opcode, Value *LHS, Value *RHS, - SCEV::NoWrapFlags Flags, bool IsSafeToHoist); - - /// Arrange for there to be a cast of V to Ty at IP, reusing an existing - /// cast if a suitable one exists, moving an existing cast if a suitable one - /// exists but isn't in the right place, or creating a new one. - Value *ReuseOrCreateCast(Value *V, Type *Ty, Instruction::CastOps Op, - BasicBlock::iterator IP); - - /// Insert a cast of V to the specified type, which must be possible with a - /// noop cast, doing what we can to share the casts. - Value *InsertNoopCastOfTo(Value *V, Type *Ty); - - /// Expand a SCEVAddExpr with a pointer type into a GEP instead of using - /// ptrtoint+arithmetic+inttoptr. - Value *expandAddToGEP(const SCEV *const *op_begin, const SCEV *const *op_end, - PointerType *PTy, Type *Ty, Value *V); - Value *expandAddToGEP(const SCEV *Op, PointerType *PTy, Type *Ty, Value *V); - - /// Find a previous Value in ExprValueMap for expand. - ScalarEvolution::ValueOffsetPair - FindValueInExprValueMap(const SCEV *S, const Instruction *InsertPt); - - Value *expand(const SCEV *S); - - /// Determine the most "relevant" loop for the given SCEV. - const Loop *getRelevantLoop(const SCEV *); - - Value *visitConstant(const SCEVConstant *S) { return S->getValue(); } - - Value *visitPtrToIntExpr(const SCEVPtrToIntExpr *S); - - Value *visitTruncateExpr(const SCEVTruncateExpr *S); - - Value *visitZeroExtendExpr(const SCEVZeroExtendExpr *S); - - Value *visitSignExtendExpr(const SCEVSignExtendExpr *S); - - Value *visitAddExpr(const SCEVAddExpr *S); - - Value *visitMulExpr(const SCEVMulExpr *S); - - Value *visitUDivExpr(const SCEVUDivExpr *S); - - Value *visitAddRecExpr(const SCEVAddRecExpr *S); - - Value *visitSMaxExpr(const SCEVSMaxExpr *S); - - Value *visitUMaxExpr(const SCEVUMaxExpr *S); - - Value *visitSMinExpr(const SCEVSMinExpr *S); - - Value *visitUMinExpr(const SCEVUMinExpr *S); - - Value *visitUnknown(const SCEVUnknown *S) { return S->getValue(); } - - void rememberInstruction(Value *I); - - bool isNormalAddRecExprPHI(PHINode *PN, Instruction *IncV, const Loop *L); - - bool isExpandedAddRecExprPHI(PHINode *PN, Instruction *IncV, const Loop *L); - - Value *expandAddRecExprLiterally(const SCEVAddRecExpr *); - PHINode *getAddRecExprPHILiterally(const SCEVAddRecExpr *Normalized, - const Loop *L, Type *ExpandTy, Type *IntTy, - Type *&TruncTy, bool &InvertStep); - Value *expandIVInc(PHINode *PN, Value *StepV, const Loop *L, Type *ExpandTy, - Type *IntTy, bool useSubtract); - - void hoistBeforePos(DominatorTree *DT, Instruction *InstToHoist, - Instruction *Pos, PHINode *LoopPhi); - - void fixupInsertPoints(Instruction *I); - - /// If required, create LCSSA PHIs for \p Users' operand \p OpIdx. If new - /// LCSSA PHIs have been created, return the LCSSA PHI available at \p User. - /// If no PHIs have been created, return the unchanged operand \p OpIdx. - Value *fixupLCSSAFormFor(Instruction *User, unsigned OpIdx); -}; - -/// Helper to remove instructions inserted during SCEV expansion, unless they -/// are marked as used. -class SCEVExpanderCleaner { - SCEVExpander &Expander; - - DominatorTree &DT; - - /// Indicates whether the result of the expansion is used. If false, the - /// instructions added during expansion are removed. - bool ResultUsed; - -public: - SCEVExpanderCleaner(SCEVExpander &Expander, DominatorTree &DT) - : Expander(Expander), DT(DT), ResultUsed(false) {} - - ~SCEVExpanderCleaner(); - - /// Indicate that the result of the expansion is used. - void markResultUsed() { ResultUsed = true; } -}; -} // namespace llvm - + assert(BudgetRemaining >= 0 && "Should have returned from inner loop."); + return false; + } + + /// Return the induction variable increment's IV operand. + Instruction *getIVIncOperand(Instruction *IncV, Instruction *InsertPos, + bool allowScale); + + /// Utility for hoisting an IV increment. + bool hoistIVInc(Instruction *IncV, Instruction *InsertPos); + + /// replace congruent phis with their most canonical representative. Return + /// the number of phis eliminated. + unsigned replaceCongruentIVs(Loop *L, const DominatorTree *DT, + SmallVectorImpl<WeakTrackingVH> &DeadInsts, + const TargetTransformInfo *TTI = nullptr); + + /// Insert code to directly compute the specified SCEV expression into the + /// program. The code is inserted into the specified block. + Value *expandCodeFor(const SCEV *SH, Type *Ty, Instruction *I) { + return expandCodeForImpl(SH, Ty, I, true); + } + + /// Insert code to directly compute the specified SCEV expression into the + /// program. The code is inserted into the SCEVExpander's current + /// insertion point. If a type is specified, the result will be expanded to + /// have that type, with a cast if necessary. + Value *expandCodeFor(const SCEV *SH, Type *Ty = nullptr) { + return expandCodeForImpl(SH, Ty, true); + } + + /// Generates a code sequence that evaluates this predicate. The inserted + /// instructions will be at position \p Loc. The result will be of type i1 + /// and will have a value of 0 when the predicate is false and 1 otherwise. + Value *expandCodeForPredicate(const SCEVPredicate *Pred, Instruction *Loc); + + /// A specialized variant of expandCodeForPredicate, handling the case when + /// we are expanding code for a SCEVEqualPredicate. + Value *expandEqualPredicate(const SCEVEqualPredicate *Pred, Instruction *Loc); + + /// Generates code that evaluates if the \p AR expression will overflow. + Value *generateOverflowCheck(const SCEVAddRecExpr *AR, Instruction *Loc, + bool Signed); + + /// A specialized variant of expandCodeForPredicate, handling the case when + /// we are expanding code for a SCEVWrapPredicate. + Value *expandWrapPredicate(const SCEVWrapPredicate *P, Instruction *Loc); + + /// A specialized variant of expandCodeForPredicate, handling the case when + /// we are expanding code for a SCEVUnionPredicate. + Value *expandUnionPredicate(const SCEVUnionPredicate *Pred, Instruction *Loc); + + /// Set the current IV increment loop and position. + void setIVIncInsertPos(const Loop *L, Instruction *Pos) { + assert(!CanonicalMode && + "IV increment positions are not supported in CanonicalMode"); + IVIncInsertLoop = L; + IVIncInsertPos = Pos; + } + + /// Enable post-inc expansion for addrecs referring to the given + /// loops. Post-inc expansion is only supported in non-canonical mode. + void setPostInc(const PostIncLoopSet &L) { + assert(!CanonicalMode && + "Post-inc expansion is not supported in CanonicalMode"); + PostIncLoops = L; + } + + /// Disable all post-inc expansion. + void clearPostInc() { + PostIncLoops.clear(); + + // When we change the post-inc loop set, cached expansions may no + // longer be valid. + InsertedPostIncValues.clear(); + } + + /// Disable the behavior of expanding expressions in canonical form rather + /// than in a more literal form. Non-canonical mode is useful for late + /// optimization passes. + void disableCanonicalMode() { CanonicalMode = false; } + + void enableLSRMode() { LSRMode = true; } + + /// Set the current insertion point. This is useful if multiple calls to + /// expandCodeFor() are going to be made with the same insert point and the + /// insert point may be moved during one of the expansions (e.g. if the + /// insert point is not a block terminator). + void setInsertPoint(Instruction *IP) { + assert(IP); + Builder.SetInsertPoint(IP); + } + + /// Clear the current insertion point. This is useful if the instruction + /// that had been serving as the insertion point may have been deleted. + void clearInsertPoint() { Builder.ClearInsertionPoint(); } + + /// Set location information used by debugging information. + void SetCurrentDebugLocation(DebugLoc L) { + Builder.SetCurrentDebugLocation(std::move(L)); + } + + /// Get location information used by debugging information. + DebugLoc getCurrentDebugLocation() const { + return Builder.getCurrentDebugLocation(); + } + + /// Return true if the specified instruction was inserted by the code + /// rewriter. If so, the client should not modify the instruction. Note that + /// this also includes instructions re-used during expansion. + bool isInsertedInstruction(Instruction *I) const { + return InsertedValues.count(I) || InsertedPostIncValues.count(I); + } + + void setChainedPhi(PHINode *PN) { ChainedPhis.insert(PN); } + + /// Try to find the ValueOffsetPair for S. The function is mainly used to + /// check whether S can be expanded cheaply. If this returns a non-None + /// value, we know we can codegen the `ValueOffsetPair` into a suitable + /// expansion identical with S so that S can be expanded cheaply. + /// + /// L is a hint which tells in which loop to look for the suitable value. + /// On success return value which is equivalent to the expanded S at point + /// At. Return nullptr if value was not found. + /// + /// Note that this function does not perform an exhaustive search. I.e if it + /// didn't find any value it does not mean that there is no such value. + /// + Optional<ScalarEvolution::ValueOffsetPair> + getRelatedExistingExpansion(const SCEV *S, const Instruction *At, Loop *L); + + /// Returns a suitable insert point after \p I, that dominates \p + /// MustDominate. Skips instructions inserted by the expander. + BasicBlock::iterator findInsertPointAfter(Instruction *I, + Instruction *MustDominate); + +private: + LLVMContext &getContext() const { return SE.getContext(); } + + /// Insert code to directly compute the specified SCEV expression into the + /// program. The code is inserted into the SCEVExpander's current + /// insertion point. If a type is specified, the result will be expanded to + /// have that type, with a cast if necessary. If \p Root is true, this + /// indicates that \p SH is the top-level expression to expand passed from + /// an external client call. + Value *expandCodeForImpl(const SCEV *SH, Type *Ty, bool Root); + + /// Insert code to directly compute the specified SCEV expression into the + /// program. The code is inserted into the specified block. If \p + /// Root is true, this indicates that \p SH is the top-level expression to + /// expand passed from an external client call. + Value *expandCodeForImpl(const SCEV *SH, Type *Ty, Instruction *I, bool Root); + + /// Recursive helper function for isHighCostExpansion. + bool isHighCostExpansionHelper( + const SCEVOperand &WorkItem, Loop *L, const Instruction &At, + int &BudgetRemaining, const TargetTransformInfo &TTI, + SmallPtrSetImpl<const SCEV *> &Processed, + SmallVectorImpl<SCEVOperand> &Worklist); + + /// Insert the specified binary operator, doing a small amount of work to + /// avoid inserting an obviously redundant operation, and hoisting to an + /// outer loop when the opportunity is there and it is safe. + Value *InsertBinop(Instruction::BinaryOps Opcode, Value *LHS, Value *RHS, + SCEV::NoWrapFlags Flags, bool IsSafeToHoist); + + /// Arrange for there to be a cast of V to Ty at IP, reusing an existing + /// cast if a suitable one exists, moving an existing cast if a suitable one + /// exists but isn't in the right place, or creating a new one. + Value *ReuseOrCreateCast(Value *V, Type *Ty, Instruction::CastOps Op, + BasicBlock::iterator IP); + + /// Insert a cast of V to the specified type, which must be possible with a + /// noop cast, doing what we can to share the casts. + Value *InsertNoopCastOfTo(Value *V, Type *Ty); + + /// Expand a SCEVAddExpr with a pointer type into a GEP instead of using + /// ptrtoint+arithmetic+inttoptr. + Value *expandAddToGEP(const SCEV *const *op_begin, const SCEV *const *op_end, + PointerType *PTy, Type *Ty, Value *V); + Value *expandAddToGEP(const SCEV *Op, PointerType *PTy, Type *Ty, Value *V); + + /// Find a previous Value in ExprValueMap for expand. + ScalarEvolution::ValueOffsetPair + FindValueInExprValueMap(const SCEV *S, const Instruction *InsertPt); + + Value *expand(const SCEV *S); + + /// Determine the most "relevant" loop for the given SCEV. + const Loop *getRelevantLoop(const SCEV *); + + Value *visitConstant(const SCEVConstant *S) { return S->getValue(); } + + Value *visitPtrToIntExpr(const SCEVPtrToIntExpr *S); + + Value *visitTruncateExpr(const SCEVTruncateExpr *S); + + Value *visitZeroExtendExpr(const SCEVZeroExtendExpr *S); + + Value *visitSignExtendExpr(const SCEVSignExtendExpr *S); + + Value *visitAddExpr(const SCEVAddExpr *S); + + Value *visitMulExpr(const SCEVMulExpr *S); + + Value *visitUDivExpr(const SCEVUDivExpr *S); + + Value *visitAddRecExpr(const SCEVAddRecExpr *S); + + Value *visitSMaxExpr(const SCEVSMaxExpr *S); + + Value *visitUMaxExpr(const SCEVUMaxExpr *S); + + Value *visitSMinExpr(const SCEVSMinExpr *S); + + Value *visitUMinExpr(const SCEVUMinExpr *S); + + Value *visitUnknown(const SCEVUnknown *S) { return S->getValue(); } + + void rememberInstruction(Value *I); + + bool isNormalAddRecExprPHI(PHINode *PN, Instruction *IncV, const Loop *L); + + bool isExpandedAddRecExprPHI(PHINode *PN, Instruction *IncV, const Loop *L); + + Value *expandAddRecExprLiterally(const SCEVAddRecExpr *); + PHINode *getAddRecExprPHILiterally(const SCEVAddRecExpr *Normalized, + const Loop *L, Type *ExpandTy, Type *IntTy, + Type *&TruncTy, bool &InvertStep); + Value *expandIVInc(PHINode *PN, Value *StepV, const Loop *L, Type *ExpandTy, + Type *IntTy, bool useSubtract); + + void hoistBeforePos(DominatorTree *DT, Instruction *InstToHoist, + Instruction *Pos, PHINode *LoopPhi); + + void fixupInsertPoints(Instruction *I); + + /// If required, create LCSSA PHIs for \p Users' operand \p OpIdx. If new + /// LCSSA PHIs have been created, return the LCSSA PHI available at \p User. + /// If no PHIs have been created, return the unchanged operand \p OpIdx. + Value *fixupLCSSAFormFor(Instruction *User, unsigned OpIdx); +}; + +/// Helper to remove instructions inserted during SCEV expansion, unless they +/// are marked as used. +class SCEVExpanderCleaner { + SCEVExpander &Expander; + + DominatorTree &DT; + + /// Indicates whether the result of the expansion is used. If false, the + /// instructions added during expansion are removed. + bool ResultUsed; + +public: + SCEVExpanderCleaner(SCEVExpander &Expander, DominatorTree &DT) + : Expander(Expander), DT(DT), ResultUsed(false) {} + + ~SCEVExpanderCleaner(); + + /// Indicate that the result of the expansion is used. + void markResultUsed() { ResultUsed = true; } +}; +} // namespace llvm + #endif #ifdef __GNUC__ diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyCFGOptions.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyCFGOptions.h index 37ace5188d..df04cc9255 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyCFGOptions.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyCFGOptions.h @@ -1,88 +1,88 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- SimplifyCFGOptions.h - Control structure for SimplifyCFG -*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// A set of parameters used to control the transforms in the SimplifyCFG pass. -// Options may change depending on the position in the optimization pipeline. -// For example, canonical form that includes switches and branches may later be -// replaced by lookup tables and selects. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TRANSFORMS_UTILS_SIMPLIFYCFGOPTIONS_H -#define LLVM_TRANSFORMS_UTILS_SIMPLIFYCFGOPTIONS_H - -namespace llvm { - -class AssumptionCache; - -struct SimplifyCFGOptions { - int BonusInstThreshold = 1; - bool ForwardSwitchCondToPhi = false; - bool ConvertSwitchToLookupTable = false; - bool NeedCanonicalLoop = true; - bool HoistCommonInsts = false; - bool SinkCommonInsts = false; - bool SimplifyCondBranch = true; - bool FoldTwoEntryPHINode = true; - - AssumptionCache *AC = nullptr; - - // Support 'builder' pattern to set members by name at construction time. - SimplifyCFGOptions &bonusInstThreshold(int I) { - BonusInstThreshold = I; - return *this; - } - SimplifyCFGOptions &forwardSwitchCondToPhi(bool B) { - ForwardSwitchCondToPhi = B; - return *this; - } - SimplifyCFGOptions &convertSwitchToLookupTable(bool B) { - ConvertSwitchToLookupTable = B; - return *this; - } - SimplifyCFGOptions &needCanonicalLoops(bool B) { - NeedCanonicalLoop = B; - return *this; - } - SimplifyCFGOptions &hoistCommonInsts(bool B) { - HoistCommonInsts = B; - return *this; - } - SimplifyCFGOptions &sinkCommonInsts(bool B) { - SinkCommonInsts = B; - return *this; - } - SimplifyCFGOptions &setAssumptionCache(AssumptionCache *Cache) { - AC = Cache; - return *this; - } - SimplifyCFGOptions &setSimplifyCondBranch(bool B) { - SimplifyCondBranch = B; - return *this; - } - - SimplifyCFGOptions &setFoldTwoEntryPHINode(bool B) { - FoldTwoEntryPHINode = B; - return *this; - } -}; - -} // namespace llvm - -#endif // LLVM_TRANSFORMS_UTILS_SIMPLIFYCFGOPTIONS_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- SimplifyCFGOptions.h - Control structure for SimplifyCFG -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// A set of parameters used to control the transforms in the SimplifyCFG pass. +// Options may change depending on the position in the optimization pipeline. +// For example, canonical form that includes switches and branches may later be +// replaced by lookup tables and selects. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_TRANSFORMS_UTILS_SIMPLIFYCFGOPTIONS_H +#define LLVM_TRANSFORMS_UTILS_SIMPLIFYCFGOPTIONS_H + +namespace llvm { + +class AssumptionCache; + +struct SimplifyCFGOptions { + int BonusInstThreshold = 1; + bool ForwardSwitchCondToPhi = false; + bool ConvertSwitchToLookupTable = false; + bool NeedCanonicalLoop = true; + bool HoistCommonInsts = false; + bool SinkCommonInsts = false; + bool SimplifyCondBranch = true; + bool FoldTwoEntryPHINode = true; + + AssumptionCache *AC = nullptr; + + // Support 'builder' pattern to set members by name at construction time. + SimplifyCFGOptions &bonusInstThreshold(int I) { + BonusInstThreshold = I; + return *this; + } + SimplifyCFGOptions &forwardSwitchCondToPhi(bool B) { + ForwardSwitchCondToPhi = B; + return *this; + } + SimplifyCFGOptions &convertSwitchToLookupTable(bool B) { + ConvertSwitchToLookupTable = B; + return *this; + } + SimplifyCFGOptions &needCanonicalLoops(bool B) { + NeedCanonicalLoop = B; + return *this; + } + SimplifyCFGOptions &hoistCommonInsts(bool B) { + HoistCommonInsts = B; + return *this; + } + SimplifyCFGOptions &sinkCommonInsts(bool B) { + SinkCommonInsts = B; + return *this; + } + SimplifyCFGOptions &setAssumptionCache(AssumptionCache *Cache) { + AC = Cache; + return *this; + } + SimplifyCFGOptions &setSimplifyCondBranch(bool B) { + SimplifyCondBranch = B; + return *this; + } + + SimplifyCFGOptions &setFoldTwoEntryPHINode(bool B) { + FoldTwoEntryPHINode = B; + return *this; + } +}; + +} // namespace llvm + +#endif // LLVM_TRANSFORMS_UTILS_SIMPLIFYCFGOPTIONS_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyIndVar.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyIndVar.h index 375bf2963a..4430fcba51 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyIndVar.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyIndVar.h @@ -22,8 +22,8 @@ #ifndef LLVM_TRANSFORMS_UTILS_SIMPLIFYINDVAR_H #define LLVM_TRANSFORMS_UTILS_SIMPLIFYINDVAR_H -#include "llvm/Analysis/ScalarEvolutionExpressions.h" -#include "llvm/IR/ConstantRange.h" +#include "llvm/Analysis/ScalarEvolutionExpressions.h" +#include "llvm/IR/ConstantRange.h" #include "llvm/IR/ValueHandle.h" namespace llvm { @@ -66,27 +66,27 @@ bool simplifyLoopIVs(Loop *L, ScalarEvolution *SE, DominatorTree *DT, LoopInfo *LI, const TargetTransformInfo *TTI, SmallVectorImpl<WeakTrackingVH> &Dead); -/// Collect information about induction variables that are used by sign/zero -/// extend operations. This information is recorded by CollectExtend and provides -/// the input to WidenIV. -struct WideIVInfo { - PHINode *NarrowIV = nullptr; - - // Widest integer type created [sz]ext - Type *WidestNativeType = nullptr; - - // Was a sext user seen before a zext? - bool IsSigned = false; -}; - -/// Widen Induction Variables - Extend the width of an IV to cover its -/// widest uses. -PHINode *createWideIV(const WideIVInfo &WI, - LoopInfo *LI, ScalarEvolution *SE, SCEVExpander &Rewriter, - DominatorTree *DT, SmallVectorImpl<WeakTrackingVH> &DeadInsts, - unsigned &NumElimExt, unsigned &NumWidened, - bool HasGuards, bool UsePostIncrementRanges); - +/// Collect information about induction variables that are used by sign/zero +/// extend operations. This information is recorded by CollectExtend and provides +/// the input to WidenIV. +struct WideIVInfo { + PHINode *NarrowIV = nullptr; + + // Widest integer type created [sz]ext + Type *WidestNativeType = nullptr; + + // Was a sext user seen before a zext? + bool IsSigned = false; +}; + +/// Widen Induction Variables - Extend the width of an IV to cover its +/// widest uses. +PHINode *createWideIV(const WideIVInfo &WI, + LoopInfo *LI, ScalarEvolution *SE, SCEVExpander &Rewriter, + DominatorTree *DT, SmallVectorImpl<WeakTrackingVH> &DeadInsts, + unsigned &NumElimExt, unsigned &NumWidened, + bool HasGuards, bool UsePostIncrementRanges); + } // end namespace llvm #endif // LLVM_TRANSFORMS_UTILS_SIMPLIFYINDVAR_H diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyLibCalls.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyLibCalls.h index 29e2eb9b3d..3d012f6277 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyLibCalls.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/SimplifyLibCalls.h @@ -66,7 +66,7 @@ private: Value *optimizeStrpCpyChk(CallInst *CI, IRBuilderBase &B, LibFunc Func); Value *optimizeStrpNCpyChk(CallInst *CI, IRBuilderBase &B, LibFunc Func); Value *optimizeStrLenChk(CallInst *CI, IRBuilderBase &B); - Value *optimizeMemPCpyChk(CallInst *CI, IRBuilderBase &B); + Value *optimizeMemPCpyChk(CallInst *CI, IRBuilderBase &B); Value *optimizeMemCCpyChk(CallInst *CI, IRBuilderBase &B); Value *optimizeSNPrintfChk(CallInst *CI, IRBuilderBase &B); Value *optimizeSPrintfChk(CallInst *CI,IRBuilderBase &B); diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/StripGCRelocates.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/StripGCRelocates.h index ab438af771..e977ff1eb4 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/StripGCRelocates.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/StripGCRelocates.h @@ -1,36 +1,36 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- StripGCRelocates.h - -----------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TRANSFORMS_UTILS_STRIPGCRELOCATES_H -#define LLVM_TRANSFORMS_UTILS_STRIPGCRELOCATES_H - -#include "llvm/IR/PassManager.h" - -namespace llvm { - -class Function; - -class StripGCRelocates : public PassInfoMixin<StripGCRelocates> { -public: - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); -}; - -} // end namespace llvm - -#endif // LLVM_TRANSFORMS_UTILS_STRIPGCRELOCATES_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- StripGCRelocates.h - -----------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_TRANSFORMS_UTILS_STRIPGCRELOCATES_H +#define LLVM_TRANSFORMS_UTILS_STRIPGCRELOCATES_H + +#include "llvm/IR/PassManager.h" + +namespace llvm { + +class Function; + +class StripGCRelocates : public PassInfoMixin<StripGCRelocates> { +public: + PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); +}; + +} // end namespace llvm + +#endif // LLVM_TRANSFORMS_UTILS_STRIPGCRELOCATES_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/StripNonLineTableDebugInfo.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/StripNonLineTableDebugInfo.h index bd010e3803..91d1d57e53 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/StripNonLineTableDebugInfo.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/StripNonLineTableDebugInfo.h @@ -1,37 +1,37 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- StripNonLineTableDebugInfo.h - -------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TRANSFORMS_UTILS_STRIPNONLINETABLEDEBUGINFO_H -#define LLVM_TRANSFORMS_UTILS_STRIPNONLINETABLEDEBUGINFO_H - -#include "llvm/IR/PassManager.h" - -namespace llvm { - -class Module; - -class StripNonLineTableDebugInfoPass - : public PassInfoMixin<StripNonLineTableDebugInfoPass> { -public: - PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); -}; - -} // end namespace llvm - -#endif // LLVM_TRANSFORMS_UTILS_STRIPNONLINETABLEDEBUGINFO_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- StripNonLineTableDebugInfo.h - -------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_TRANSFORMS_UTILS_STRIPNONLINETABLEDEBUGINFO_H +#define LLVM_TRANSFORMS_UTILS_STRIPNONLINETABLEDEBUGINFO_H + +#include "llvm/IR/PassManager.h" + +namespace llvm { + +class Module; + +class StripNonLineTableDebugInfoPass + : public PassInfoMixin<StripNonLineTableDebugInfoPass> { +public: + PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); +}; + +} // end namespace llvm + +#endif // LLVM_TRANSFORMS_UTILS_STRIPNONLINETABLEDEBUGINFO_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h index dcb046c476..d836f64cc0 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h @@ -14,24 +14,24 @@ //===----------------------------------------------------------------------===// // // This pass is used to ensure that functions have at most one return and one -// unreachable instruction in them. +// unreachable instruction in them. // //===----------------------------------------------------------------------===// #ifndef LLVM_TRANSFORMS_UTILS_UNIFYFUNCTIONEXITNODES_H #define LLVM_TRANSFORMS_UTILS_UNIFYFUNCTIONEXITNODES_H -#include "llvm/IR/PassManager.h" +#include "llvm/IR/PassManager.h" #include "llvm/Pass.h" namespace llvm { class BasicBlock; -class UnifyFunctionExitNodesLegacyPass : public FunctionPass { +class UnifyFunctionExitNodesLegacyPass : public FunctionPass { public: static char ID; // Pass identification, replacement for typeid - UnifyFunctionExitNodesLegacyPass(); + UnifyFunctionExitNodesLegacyPass(); // We can preserve non-critical-edgeness when we unify function exit nodes void getAnalysisUsage(AnalysisUsage &AU) const override; @@ -41,12 +41,12 @@ public: Pass *createUnifyFunctionExitNodesPass(); -class UnifyFunctionExitNodesPass - : public PassInfoMixin<UnifyFunctionExitNodesPass> { -public: - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); -}; - +class UnifyFunctionExitNodesPass + : public PassInfoMixin<UnifyFunctionExitNodesPass> { +public: + PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); +}; + } // end namespace llvm #endif // LLVM_TRANSFORMS_UTILS_UNIFYFUNCTIONEXITNODES_H diff --git a/contrib/libs/llvm12/include/llvm/Transforms/Utils/UnifyLoopExits.h b/contrib/libs/llvm12/include/llvm/Transforms/Utils/UnifyLoopExits.h index ef6ef6f92b..642da24966 100644 --- a/contrib/libs/llvm12/include/llvm/Transforms/Utils/UnifyLoopExits.h +++ b/contrib/libs/llvm12/include/llvm/Transforms/Utils/UnifyLoopExits.h @@ -1,33 +1,33 @@ -#pragma once - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-parameter" -#endif - -//===- UnifyLoopExits.h - Redirect exiting edges to one block -*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TRANSFORMS_UTILS_UNIFYLOOPEXITS_H -#define LLVM_TRANSFORMS_UTILS_UNIFYLOOPEXITS_H - -#include "llvm/IR/PassManager.h" - -namespace llvm { - -class UnifyLoopExitsPass : public PassInfoMixin<UnifyLoopExitsPass> { -public: - PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); -}; -} // namespace llvm - -#endif // LLVM_TRANSFORMS_UTILS_UNIFYLOOPEXITS_H - -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- UnifyLoopExits.h - Redirect exiting edges to one block -*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_TRANSFORMS_UTILS_UNIFYLOOPEXITS_H +#define LLVM_TRANSFORMS_UTILS_UNIFYLOOPEXITS_H + +#include "llvm/IR/PassManager.h" + +namespace llvm { + +class UnifyLoopExitsPass : public PassInfoMixin<UnifyLoopExitsPass> { +public: + PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); +}; +} // namespace llvm + +#endif // LLVM_TRANSFORMS_UTILS_UNIFYLOOPEXITS_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif |