[llvm] 947b656 - [PGO] Check that PGOOpt exists before using PGOOpt->ColdOptType (#89139)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 18 11:22:14 PDT 2024
Author: Arthur Eubanks
Date: 2024-04-18T11:22:10-07:00
New Revision: 947b656add053a8c9a36cab27b5c6e8eb9c426f7
URL: https://github.com/llvm/llvm-project/commit/947b656add053a8c9a36cab27b5c6e8eb9c426f7
DIFF: https://github.com/llvm/llvm-project/commit/947b656add053a8c9a36cab27b5c6e8eb9c426f7.diff
LOG: [PGO] Check that PGOOpt exists before using PGOOpt->ColdOptType (#89139)
This means that the pass is unusable without some sort of profile. We
can revisit this decision later if we want to support running this pass
without a profile.
Added:
Modified:
llvm/lib/Passes/PassBuilderPipelines.cpp
llvm/test/Instrumentation/PGOForceFunctionAttrs/basic.ll
Removed:
################################################################################
diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp
index 3bb2ce0ae3460b..90ba3b541553e2 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -1169,7 +1169,7 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
if (EnableSyntheticCounts && !PGOOpt)
MPM.addPass(SyntheticCountsPropagation());
- if (EnablePGOForceFunctionAttrs)
+ if (EnablePGOForceFunctionAttrs && PGOOpt)
MPM.addPass(PGOForceFunctionAttrsPass(PGOOpt->ColdOptType));
MPM.addPass(AlwaysInlinerPass(/*InsertLifetimeIntrinsics=*/true));
diff --git a/llvm/test/Instrumentation/PGOForceFunctionAttrs/basic.ll b/llvm/test/Instrumentation/PGOForceFunctionAttrs/basic.ll
index 1da047176e99ad..55bdb2f69ad16a 100644
--- a/llvm/test/Instrumentation/PGOForceFunctionAttrs/basic.ll
+++ b/llvm/test/Instrumentation/PGOForceFunctionAttrs/basic.ll
@@ -5,6 +5,7 @@
; Should be no changes without profile data
; RUN: opt < %s -passes=pgo-force-function-attrs -S -pgo-cold-func-opt=minsize | FileCheck %s --check-prefixes=NONE,CHECK
+; RUN: opt < %s -passes='default<O2>' -enable-pgo-force-function-attrs -S -pgo-cold-func-opt=minsize | FileCheck %s --check-prefixes=O2
; NONE-NOT: Function Attrs:
; OPTSIZE: Function Attrs: optsize{{$}}
@@ -37,6 +38,9 @@
; CHECK-NOT: Function Attrs: {{.*}}minsize
; CHECK-NOT: Function Attrs: {{.*}}optnone
+; O2: define void @cold_attr(){{.*}} #[[ATTR:[0-9]+]]
+; O2-NOT: #[[ATTR]] = {{.*}}minsize
+
@s = global i32 0
define void @cold() !prof !27 {
More information about the llvm-commits
mailing list