[llvm] [FunctionAttrs] deduce attr `cold` on functions if all CG paths call a `cold` function (PR #101298)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 18 07:48:17 PDT 2024
================
@@ -1760,6 +1761,70 @@ static void addNoReturnAttrs(const SCCNodeSet &SCCNodes,
}
}
+static bool
+allBBPathsGoThroughCold(BasicBlock *BB,
+ SmallDenseMap<BasicBlock *, bool, 16> &Visited) {
+ // If BB contains a cold callsite this path through the CG is cold.
+ if (any_of(*BB, [](Instruction &I) {
+ if (auto *CB = dyn_cast<CallBase>(&I))
+ return CB->hasFnAttr(Attribute::Cold);
+ return false;
----------------
nikic wrote:
I'd add a note that this assumes throwing an diverging code paths are cold, which is why this does not check for guaranteed-to-transfer.
https://github.com/llvm/llvm-project/pull/101298
More information about the llvm-commits
mailing list