https://github.com/snehasish updated https://github.com/llvm/llvm-project/pull/179758
>From 950190ddcc169c3b1c829f1f6e237dace9eaf894 Mon Sep 17 00:00:00 2001 From: Snehasish Kumar <[email protected]> Date: Tue, 3 Feb 2026 04:37:37 +0000 Subject: [PATCH] InstCombine: Set unknown profile metadata in memchr-to-select folding --- llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | 11 ++++++++++- llvm/utils/profcheck-xfail.txt | 1 - 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp index 5de9230cdc485..80dde3db360c8 100644 --- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -485,10 +485,19 @@ static Value* memChrToCharCompare(CallInst *CI, Value *NBytes, Value *Zero = ConstantInt::get(NBytes->getType(), 0); Value *And = B.CreateICmpNE(NBytes, Zero); Cmp = B.CreateLogicalAnd(And, Cmp); + if (!ProfcheckDisableMetadataFixes) + if (auto *I = dyn_cast<Instruction>(Cmp)) + setExplicitlyUnknownBranchWeightsIfProfiled(*I, DEBUG_TYPE, + CI->getFunction()); } Value *NullPtr = Constant::getNullValue(CI->getType()); - return B.CreateSelect(Cmp, Src, NullPtr); + Value *Res = B.CreateSelect(Cmp, Src, NullPtr); + if (!ProfcheckDisableMetadataFixes) + if (auto *I = dyn_cast<Instruction>(Res)) + setExplicitlyUnknownBranchWeightsIfProfiled(*I, DEBUG_TYPE, + CI->getFunction()); + return Res; } Value *LibCallSimplifier::optimizeStrChr(CallInst *CI, IRBuilderBase &B) { diff --git a/llvm/utils/profcheck-xfail.txt b/llvm/utils/profcheck-xfail.txt index 94d718eb6b1fb..1758afc920258 100644 --- a/llvm/utils/profcheck-xfail.txt +++ b/llvm/utils/profcheck-xfail.txt @@ -225,7 +225,6 @@ Transforms/InstCombine/load.ll Transforms/InstCombine/load-select.ll Transforms/InstCombine/loadstore-metadata.ll Transforms/InstCombine/logical-select.ll -Transforms/InstCombine/memchr-11.ll Transforms/InstCombine/memchr-2.ll Transforms/InstCombine/memchr-3.ll Transforms/InstCombine/memchr-6.ll _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
