[llvm-branch-commits] [llvm] [NFC] (PR #80762)

Mingming Liu via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Feb 7 18:21:11 PST 2024


================
@@ -1260,6 +1260,8 @@ void annotateValueSite(Module &M, Instruction &Inst,
                        ArrayRef<InstrProfValueData> VDs,
                        uint64_t Sum, InstrProfValueKind ValueKind,
                        uint32_t MaxMDCount) {
+  if (VDs.empty())
----------------
minglotus-6 wrote:

yes, the check `NumPromoted == NumVals` is removed so `NumVals` doesn't need to be passed as an argument to `tryToPromoteWithFuncCmp`.
- `NumVals == ICallProfDataRef.size()` is [always true](https://github.com/llvm/llvm-project/blob/0d7f232baf6103529844c8977324bd45b21ad923/llvm/lib/Analysis/IndirectCallPromotionAnalysis.cpp#L98), and `NumPromoted <= NumVals` is also true, so `ICallProfDataRef.slice(NumPromoted)` still returns a valid ArrayRef after the check is removed.

On a second thought, when `if(TotalCount != 0)` is true, it's also guaranteed `ICallProfDataRef.slice(NumPromoted)` is not empty so that `ICallProfDataRef.slice(NumPromoted)` returns a valid ArrayRef. Added an assert (`assert(NumPromoted <= ICallProfDataRef.size()`) just to make the condition that `.slice` relies on more explicit.

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


More information about the llvm-branch-commits mailing list