diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp --- a/bolt/lib/Rewrite/RewriteInstance.cpp +++ b/bolt/lib/Rewrite/RewriteInstance.cpp @@ -607,10 +607,19 @@ errs() << "BOLT-WARNING: fail in building GUID2FuncDescMap\n"; return; } + + MCPseudoProbeDecoder::Uint64Set GuidFilter; + MCPseudoProbeDecoder::Uint64Map FuncStartAddrs; + for (const BinaryFunction *F : BC->getAllBinaryFunctions()) { + for (const MCSymbol *Sym : F->getSymbols()) { + FuncStartAddrs[Function::getGUID(NameResolver::restore(Sym->getName()))] = + F->getAddress(); + } + } Contents = PseudoProbeSection->getContents(); if (!BC->ProbeDecoder.buildAddress2ProbeMap( - reinterpret_cast(Contents.data()), - Contents.size())) { + reinterpret_cast(Contents.data()), Contents.size(), + GuidFilter, FuncStartAddrs)) { BC->ProbeDecoder.getAddress2ProbesMap().clear(); errs() << "BOLT-WARNING: fail in building Address2ProbeMap\n"; return; @@ -3407,6 +3416,8 @@ // Address of the first probe is absolute. // Other probes' address are represented by delta auto EmitDecodedPseudoProbe = [&](MCDecodedPseudoProbe *&CurProbe) { + assert(!isSentinelProbe(CurProbe->getAttributes()) && + "Sentinel probes should not be emitted"); EmitULEB128IntValue(CurProbe->getIndex()); uint8_t PackedType = CurProbe->getType() | (CurProbe->getAttributes() << 4); uint8_t Flag = @@ -3511,9 +3522,17 @@ reinterpret_cast(DescContents.data()), DescContents.size()); StringRef ProbeContents = PseudoProbeSection->getOutputContents(); + MCPseudoProbeDecoder::Uint64Set GuidFilter; + MCPseudoProbeDecoder::Uint64Map FuncStartAddrs; + for (const BinaryFunction *F : BC->getAllBinaryFunctions()) { + const uint64_t Addr = + F->isEmitted() ? F->getOutputAddress() : F->getAddress(); + FuncStartAddrs[Function::getGUID( + NameResolver::restore(F->getOneName()))] = Addr; + } DummyDecoder.buildAddress2ProbeMap( reinterpret_cast(ProbeContents.data()), - ProbeContents.size()); + ProbeContents.size(), GuidFilter, FuncStartAddrs); DummyDecoder.printProbesForAllAddresses(outs()); } }