|
23 | 23 | #include "bolt/RuntimeLibs/RuntimeLibrary.h"
|
24 | 24 | #include "llvm/ADT/AddressRanges.h"
|
25 | 25 | #include "llvm/ADT/ArrayRef.h"
|
| 26 | +#include "llvm/ADT/EquivalenceClasses.h" |
26 | 27 | #include "llvm/ADT/StringMap.h"
|
27 | 28 | #include "llvm/ADT/iterator.h"
|
28 | 29 | #include "llvm/BinaryFormat/Dwarf.h"
|
|
32 | 33 | #include "llvm/MC/MCContext.h"
|
33 | 34 | #include "llvm/MC/MCObjectFileInfo.h"
|
34 | 35 | #include "llvm/MC/MCObjectWriter.h"
|
| 36 | +#include "llvm/MC/MCPseudoProbe.h" |
35 | 37 | #include "llvm/MC/MCSectionELF.h"
|
36 | 38 | #include "llvm/MC/MCSectionMachO.h"
|
37 | 39 | #include "llvm/MC/MCStreamer.h"
|
@@ -240,12 +242,19 @@ class BinaryContext {
|
240 | 242 | /// Function fragments to skip.
|
241 | 243 | std::unordered_set<BinaryFunction *> FragmentsToSkip;
|
242 | 244 |
|
| 245 | + /// Fragment equivalence classes to query belonging to the same "family" in |
| 246 | + /// presence of multiple fragments/multiple parents. |
| 247 | + EquivalenceClasses<const BinaryFunction *> FragmentClasses; |
| 248 | + |
243 | 249 | /// The runtime library.
|
244 | 250 | std::unique_ptr<RuntimeLibrary> RtLibrary;
|
245 | 251 |
|
246 | 252 | /// DWP Context.
|
247 | 253 | std::shared_ptr<DWARFContext> DWPContext;
|
248 | 254 |
|
| 255 | + /// Decoded pseudo probes. |
| 256 | + std::shared_ptr<MCPseudoProbeDecoder> PseudoProbeDecoder; |
| 257 | + |
249 | 258 | /// A map of DWO Ids to CUs.
|
250 | 259 | using DWOIdToCUMapType = std::unordered_map<uint64_t, DWARFUnit *>;
|
251 | 260 | DWOIdToCUMapType DWOCUs;
|
@@ -377,6 +386,15 @@ class BinaryContext {
|
377 | 386 | RtLibrary = std::move(Lib);
|
378 | 387 | }
|
379 | 388 |
|
| 389 | + const MCPseudoProbeDecoder *getPseudoProbeDecoder() const { |
| 390 | + return PseudoProbeDecoder.get(); |
| 391 | + } |
| 392 | + |
| 393 | + void setPseudoProbeDecoder(std::shared_ptr<MCPseudoProbeDecoder> Decoder) { |
| 394 | + assert(!PseudoProbeDecoder && "Cannot set pseudo probe decoder twice."); |
| 395 | + PseudoProbeDecoder = Decoder; |
| 396 | + } |
| 397 | + |
380 | 398 | /// Return BinaryFunction containing a given \p Address or nullptr if
|
381 | 399 | /// no registered function contains the \p Address.
|
382 | 400 | ///
|
@@ -431,6 +449,9 @@ class BinaryContext {
|
431 | 449 | return nullptr;
|
432 | 450 | }
|
433 | 451 |
|
| 452 | + /// Deregister JumpTable registered at a given \p Address and delete it. |
| 453 | + void deleteJumpTable(uint64_t Address); |
| 454 | + |
434 | 455 | unsigned getDWARFEncodingSize(unsigned Encoding) {
|
435 | 456 | if (Encoding == dwarf::DW_EH_PE_omit)
|
436 | 457 | return 0;
|
@@ -1016,7 +1037,15 @@ class BinaryContext {
|
1016 | 1037 | /// fragment_name == parent_name.cold(.\d+)?
|
1017 | 1038 | /// True if the Function is registered, false if the check failed.
|
1018 | 1039 | bool registerFragment(BinaryFunction &TargetFunction,
|
1019 |
| - BinaryFunction &Function) const; |
| 1040 | + BinaryFunction &Function); |
| 1041 | + |
| 1042 | + /// Return true if two functions belong to the same "family": are fragments |
| 1043 | + /// of one another, or fragments of the same parent, or transitively fragment- |
| 1044 | + /// related. |
| 1045 | + bool areRelatedFragments(const BinaryFunction *LHS, |
| 1046 | + const BinaryFunction *RHS) const { |
| 1047 | + return FragmentClasses.isEquivalent(LHS, RHS); |
| 1048 | + } |
1020 | 1049 |
|
1021 | 1050 | /// Add interprocedural reference for \p Function to \p Address
|
1022 | 1051 | void addInterproceduralReference(BinaryFunction *Function, uint64_t Address) {
|
@@ -1436,10 +1465,7 @@ class BinaryContext {
|
1436 | 1465 | std::unique_ptr<MCObjectWriter> OW = MAB->createObjectWriter(OS);
|
1437 | 1466 | std::unique_ptr<MCStreamer> Streamer(TheTarget->createMCObjectStreamer(
|
1438 | 1467 | *TheTriple, *Ctx, std::unique_ptr<MCAsmBackend>(MAB), std::move(OW),
|
1439 |
| - std::unique_ptr<MCCodeEmitter>(MCE), *STI, |
1440 |
| - /* RelaxAll */ false, |
1441 |
| - /* IncrementalLinkerCompatible */ false, |
1442 |
| - /* DWARFMustBeAtTheEnd */ false)); |
| 1468 | + std::unique_ptr<MCCodeEmitter>(MCE), *STI)); |
1443 | 1469 | return Streamer;
|
1444 | 1470 | }
|
1445 | 1471 |
|
|
0 commit comments