[clang] [PGO] Add ability to mark cold functions as optsize/minsize/optnone (PR #69030)

Arthur Eubanks via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 16 09:42:51 PDT 2023


================
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Transforms/Instrumentation/MarkColdFunctions.h"
+#include "llvm/Analysis/BlockFrequencyInfo.h"
+#include "llvm/Analysis/ProfileSummaryInfo.h"
+#include "llvm/IR/PassManager.h"
+
+using namespace llvm;
+
+PreservedAnalyses MarkColdFunctionsPass::run(Module &M,
----------------
aeubanks wrote:

Having a global option determine how to handle `cold` makes the IR more complicated. Reusing something that already exists and is being used is nicer.

Another alternative is to rely on the profile loaders to mark functions as `cold`, then this pass only looks at functions marked `cold`. WDYT?

It looks like iFDO marks cold functions as `cold`, but sample FDO doesn't. If sample FDO is inaccurate then marking functions as `cold` may be bad, so I assume that's why we don't mark functions as `cold` for sample FDO. But there's also the "accurate" flag that says that the sample profile is accurate and functions not in the profile are actually cold. In that case we should mark functions as `cold`?

https://github.com/llvm/llvm-project/pull/69030


More information about the cfe-commits mailing list