From 77226a03dca98e6237c1068f2652fe41bea7b687 Mon Sep 17 00:00:00 2001 From: Diego Novillo Date: Fri, 24 May 2013 12:26:52 +0000 Subject: Add a new function attribute 'cold' to functions. Other than recognizing the attribute, the patch does little else. It changes the branch probability analyzer so that edges into blocks postdominated by a cold function are given low weight. Added analysis and code generation tests. Added documentation for the new attribute. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182638 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 1 + include/llvm/Analysis/BranchProbabilityInfo.h | 4 ++++ include/llvm/IR/Attributes.h | 1 + 3 files changed, 6 insertions(+) (limited to 'include') diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index 0920c5d0b0..409c0f15c5 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -166,6 +166,7 @@ typedef enum { and the path forward agreed upon. LLVMAddressSafety = 1ULL << 32, LLVMStackProtectStrongAttribute = 1ULL<<33 + LLVMCold = 1ULL << 34 */ } LLVMAttribute; diff --git a/include/llvm/Analysis/BranchProbabilityInfo.h b/include/llvm/Analysis/BranchProbabilityInfo.h index 6c23f7c3ae..4ff7121728 100644 --- a/include/llvm/Analysis/BranchProbabilityInfo.h +++ b/include/llvm/Analysis/BranchProbabilityInfo.h @@ -131,11 +131,15 @@ private: /// \brief Track the set of blocks directly succeeded by a returning block. SmallPtrSet PostDominatedByUnreachable; + /// \brief Track the set of blocks that always lead to a cold call. + SmallPtrSet PostDominatedByColdCall; + /// \brief Get sum of the block successors' weights. uint32_t getSumForBlock(const BasicBlock *BB) const; bool calcUnreachableHeuristics(BasicBlock *BB); bool calcMetadataWeights(BasicBlock *BB); + bool calcColdCallHeuristics(BasicBlock *BB); bool calcPointerHeuristics(BasicBlock *BB); bool calcLoopBranchHeuristics(BasicBlock *BB); bool calcZeroHeuristics(BasicBlock *BB); diff --git a/include/llvm/IR/Attributes.h b/include/llvm/IR/Attributes.h index 2c7da6485d..0d14709fe9 100644 --- a/include/llvm/IR/Attributes.h +++ b/include/llvm/IR/Attributes.h @@ -68,6 +68,7 @@ public: ///< 0 means unaligned (different from align(1)) AlwaysInline, ///< inline=always ByVal, ///< Pass structure by value + Cold, ///< Marks function as being in a cold path. InlineHint, ///< Source said inlining was desirable InReg, ///< Force argument to be passed in register MinSize, ///< Function must be optimized for size first -- cgit v1.2.3