10 Commits

Author SHA1 Message Date
Mircea Trofin
b15845c005
[ctxprof] dump profiles using yaml (for testing) (#123108)
This is a follow-up from PR #122545, which enabled converting yaml to contextual profiles.

This change uses the lower level yaml APIs because:
- the mapping APIs `llvm::yaml` offers don't work with `const` values, because they (the APIs) want to enable both serialization and deserialization
- building a helper data structure would be an alternative, but it'd be either memory-consuming or overly-complex design, given the recursive nature of the contextual profiles.
2025-01-15 16:49:59 -08:00
Kazu Hirata
4f1b20f023
[ProfileData] Remove unused includes (NFC) (#116751)
Identified with misc-include-cleaner.
2024-11-19 19:42:20 -08:00
Mircea Trofin
885ac29910 [nfc][ctx_prof] Change some internal "set" types
- the set used for targets under a callsite is simpler to use if iterators
  are stable (it gets manipulated during updates)
- the set used to fetch the transitive closure of GUIDs under a node can
  be left as a choice to the user.
2024-09-12 10:34:53 -07:00
Mircea Trofin
6b47772a4b
[nfc][ctx_prof] Rename PGOContextualProfile to PGOCtxProfContext (#102209) 2024-08-06 17:41:38 -04:00
Mircea Trofin
cc7308a156
[ctx_prof] Make the profile output analyzable by llvm-bcanalyzer (#99563)
This requires output-ing a "Magic" 4-byte header. We also emit a block info block, to describe our blocks and records. The output of `llvm-bcanalyzer` would look like:

```
<BLOCKINFO_BLOCK/>
<Metadata NumWords=17 BlockCodeSize=2>
  <Version op0=1/>
  <Context NumWords=13 BlockCodeSize=2>
    <GUID op0=2/>
    <Counters op0=1 op1=2 op2=3/>
```

Instead of having `Unknown` for block and record IDs.
2024-07-23 08:59:07 -04:00
Mircea Trofin
fc8775e214 "Reapply "[ctx_profile] Profile reader and writer" (#92199)"
This reverts commit 2c54bf497f7d7aecd24f4b849ee08e37a3519611.

Fixed gcc-7 issue.
2024-05-15 12:47:00 -07:00
Mehdi Amini
2c54bf497f Revert "Reapply "[ctx_profile] Profile reader and writer" (#92199)"
This reverts commit c19f2c773b0e23fd623502888894add822079f63.

Broke the gcc-7 bot.
2024-05-15 11:44:50 -07:00
Mircea Trofin
c19f2c773b Reapply "[ctx_profile] Profile reader and writer" (#92199)
This reverts commit 03c7458a3603396d2d0e1dee43399d3d1664a264.

One of the problems was addressed in #92208

The other problem: needed to add `BitstreamReader` to the list of
link deps of `LLVMProfileData`
2024-05-15 10:59:35 -07:00
Mircea Trofin
03c7458a36
Revert "[ctx_profile] Profile reader and writer" (#92199)
Reverts llvm/llvm-project#91859

Buildbot failures.
2024-05-14 18:07:58 -07:00
Mircea Trofin
dfdc3dcbe7
[ctx_profile] Profile reader and writer (#91859)
Utility converting a profile coming from `compiler_rt` to bitstream, and
a reader.

`PGOCtxProfileWriter::write` would be used as the `Writer` parameter for
`__llvm_ctx_profile_fetch` API. This is expected to happen in user code,
for example in the RPC hanler tasked with collecting a profile, and
would look like this:

```
// set up an output stream "Out", which could contain other stuff
{
  // constructing the Writer will start the section, in Out, containing
  // the collected contextual profiles.
  PGOCtxProfWriter Writer(Out);
  __llvm_ctx_profile_fetch(&Writer, +[](void* W, const ContextNode &N) {
    reinterpret_cast<PGOCtxProfWriter*>(W)->write(N);
  });
  // Writer going out of scope will finish up the section.
}
```

The reader produces a data structure suitable for maintenance during IPO
transformations.
2024-05-14 18:01:23 -07:00