[llvm] [CodeGen] Preserve branch weights from PGO profile during instruction selection at -O0 (PR #161620)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 7 11:58:56 PDT 2025


================
@@ -229,6 +229,19 @@ static bool dontUseFastISelFor(const Function &Fn) {
   });
 }
 
+static bool shouldRegisterPGOPasses(const TargetMachine &TM,
+                                    CodeGenOptLevel OptLevel) {
+  if (OptLevel != CodeGenOptLevel::None)
+    return true;
+  if (TM.getPGOOption()) {
+    const PGOOptions &Options = *TM.getPGOOption();
+    return Options.Action == PGOOptions::PGOAction::IRUse ||
+           Options.Action == PGOOptions::PGOAction::SampleUse ||
+           Options.CSAction != PGOOptions::CSPGOAction::NoCSAction;
----------------
WenleiHe wrote:

check `Options.CSAction == PGOOptions::CSPGOAction::CSIRUse` to be consistent? 

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


More information about the llvm-commits mailing list