diff --git a/llvm/tools/llvm-profgen/ProfiledBinary.h b/llvm/tools/llvm-profgen/ProfiledBinary.h --- a/llvm/tools/llvm-profgen/ProfiledBinary.h +++ b/llvm/tools/llvm-profgen/ProfiledBinary.h @@ -32,6 +32,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Path.h" #include "llvm/Transforms/IPO/SampleContextTracker.h" +#include #include #include #include @@ -454,7 +455,13 @@ SmallVector ProbeInlineContext; ProbeDecoder.getInlineContextForProbe(Probe, ProbeInlineContext, IncludeLeaf); - for (auto &Callsite : ProbeInlineContext) { + for (uint32_t I = 0; I < ProbeInlineContext.size(); I++) { + auto &Callsite = ProbeInlineContext[I]; + // Ignore the context if the probe of the callsite is zero. + if(Callsite.second == 0 && I != ProbeInlineContext.size() - 1) { + InlineContextStack.clear(); + continue; + } InlineContextStack.emplace_back(Callsite.first, LineLocation(Callsite.second, 0)); }