diff --git a/llvm/lib/MC/MCPseudoProbe.cpp b/llvm/lib/MC/MCPseudoProbe.cpp --- a/llvm/lib/MC/MCPseudoProbe.cpp +++ b/llvm/lib/MC/MCPseudoProbe.cpp @@ -446,8 +446,12 @@ Cur = Cur->getOrAddNode(std::make_tuple(Guid, Index)); Cur->Guid = Guid; if (IsTopLevelFunc && !EncodingIsAddrBased) { - if (auto V = FuncStartAddrs.lookup(Guid)) + if (auto V = FuncStartAddrs.lookup(Guid)) { LastAddr = V; + } else { + // The probe metadata is for a dead function, so discard it. + Cur = nullptr; + } } } @@ -490,8 +494,12 @@ if (isSentinelProbe(Attr)) { // For sentinel probe, the addr field actually stores the GUID of the // split function. Convert it to the real address. - if (auto V = FuncStartAddrs.lookup(Addr)) + if (auto V = FuncStartAddrs.lookup(Addr)) { Addr = V; + } else { + // The probe metadata is for a dead function, so discard it. + Cur = nullptr; + } } else { // For now we assume all probe encoding should be either based on // leading probe address or function start address.