diff --git a/llvm/tools/llvm-profgen/ProfiledBinary.cpp b/llvm/tools/llvm-profgen/ProfiledBinary.cpp --- a/llvm/tools/llvm-profgen/ProfiledBinary.cpp +++ b/llvm/tools/llvm-profgen/ProfiledBinary.cpp @@ -219,11 +219,12 @@ ContextVec.append(ExpandedContext); } + assert(ContextVec.size() && "Context length should be at least 1"); + // Compress the context string except for the leaf frame auto LeafFrame = ContextVec.back(); LeafFrame.Callsite = LineLocation(0, 0); ContextVec.pop_back(); - assert(ContextVec.size() && "Context length should be at least 1"); CSProfileGenerator::compressRecursionContext(ContextVec); CSProfileGenerator::trimContext(ContextVec); ContextVec.push_back(LeafFrame);