[llvm] [ProfCheck] Add utility to get a MDNode for unknown branch weights (PR #180389)

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 8 10:15:08 PST 2026


================
@@ -289,6 +289,18 @@ void llvm::setExplicitlyUnknownBranchWeightsIfProfiled(Instruction &I,
     setExplicitlyUnknownBranchWeights(I, PassName);
 }
 
+MDNode *llvm::getExplicitlyUnknownBranchWeightsIfProfiled(Function &F,
+                                                          StringRef PassName) {
+  if (std::optional<Function::ProfileCount> EC = F.getEntryCount();
+      !EC || EC->getCount() == 0)
----------------
boomanaiden154 wrote:

Ack. I'm going to land this as-is. If we decide on some improvement here, we should do it in a follow up and uniformly to the other functions.

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


More information about the llvm-commits mailing list