<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/llvm/lib/ProfileData/SampleProfReader.cpp, branch main</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/'/>
<entry>
<title>[Support] Deprecate one form of support::endian::read (NFC) (#160979)</title>
<updated>2025-09-27T16:05:16+00:00</updated>
<author>
<name>Kazu Hirata</name>
<email>kazu@google.com</email>
</author>
<published>2025-09-27T16:05:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=798ccd2e4722b228317e8a30dd3624a0308a927e'/>
<id>798ccd2e4722b228317e8a30dd3624a0308a927e</id>
<content type='text'>
This is a follow-up to #156140, which deprecated one form of write.

We have two forms of read:

  template &lt;typename value_type, std::size_t alignment&gt;
[[nodiscard]] inline value_type read(const void *memory, endianness
endian)

template &lt;typename value_type, endianness endian, std::size_t alignment&gt;
  [[nodiscard]] inline value_type read(const void *memory)

The difference is that endian is a function parameter in the former
but a template parameter in the latter.

This patch streamlines the code by migrating the use of the latter to
the former while deprecating the latter.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is a follow-up to #156140, which deprecated one form of write.

We have two forms of read:

  template &lt;typename value_type, std::size_t alignment&gt;
[[nodiscard]] inline value_type read(const void *memory, endianness
endian)

template &lt;typename value_type, endianness endian, std::size_t alignment&gt;
  [[nodiscard]] inline value_type read(const void *memory)

The difference is that endian is a function parameter in the former
but a template parameter in the latter.

This patch streamlines the code by migrating the use of the latter to
the former while deprecating the latter.</pre>
</div>
</content>
</entry>
<entry>
<title>[SampleFDO][TypeProf]Support vtable type profiling for ext-binary and text format (#148002)</title>
<updated>2025-09-12T22:58:16+00:00</updated>
<author>
<name>Mingming Liu</name>
<email>mingmingl@google.com</email>
</author>
<published>2025-09-12T22:58:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=52c583b3f95a0e666ab837e39a5db900b66adf15'/>
<id>52c583b3f95a0e666ab837e39a5db900b66adf15</id>
<content type='text'>
This change extends SampleFDO ext-binary and text format to record the
vtable symbols and their counts for virtual calls inside a function. The
vtable profiles will allow the compiler to annotate vtable types on IR
instructions and perform vtable-based indirect call promotion. An RFC is
in
https://discourse.llvm.org/t/rfc-vtable-type-profiling-for-samplefdo/87283

Given a function below, the before vs after of a function's profile is
illustrated in text format in the table:

```
__attribute__((noinline)) int loop_func(int i, int a, int b) {
    Base *ptr = createType(i);

    int sum = ptr-&gt;func(a, b);
    
    delete ptr;
    
    return sum;
}
```

| before | after |
| --- | --- |
| Samples collected in the function's body { &lt;br&gt; 0: 636241 &lt;br&gt; 1:
681458, calls: _Z10createTypei:681458 &lt;br&gt; 3: 543499, calls:
_ZN12_GLOBAL__N_18Derived24funcEii:410621 _ZN8Derived14funcEii:132878
&lt;br&gt; 5.1: 602201, calls: _ZN12_GLOBAL__N_18Derived2D0Ev:454635
_ZN8Derived1D0Ev:147566 &lt;br&gt; 7: 511057 &lt;br&gt; } | Samples collected in the
function's body { &lt;br&gt; 0: 636241 &lt;br&gt; 1: 681458, calls:
_Z10createTypei:681458 &lt;br&gt; 3: 543499, calls:
_ZN12_GLOBAL__N_18Derived24funcEii:410621 _ZN8Derived14funcEii:132878
&lt;br&gt; 3: vtables: _ZTV8Derived1:1377 _ZTVN12_GLOBAL__N_18Derived2E:4250
&lt;br&gt; 5.1: 602201, calls: _ZN12_GLOBAL__N_18Derived2D0Ev:454635
_ZN8Derived1D0Ev:147566 &lt;br&gt; 5.1: vtables: _ZTV8Derived1:227
_ZTVN12_GLOBAL__N_18Derived2E:765 &lt;br&gt; 7: 511057 &lt;br&gt; } |

Key points for this change:
1. In-memory representation of vtable profiles
* A field of type `map&lt;LineLocation, map&lt;FunctionId, uint64_t&gt;&gt;` is
introduced in a function's in-memory representation
[FunctionSamples](https://github.com/llvm/llvm-project/blob/ccc416312ed72e92a885425d9cb9c01f9afa58eb/llvm/include/llvm/ProfileData/SampleProf.h#L749-L754).
2. The vtable counters for one LineLocation represents the relative
frequency among vtables for this LineLocation. They are not required to
be comparable across LineLocations.
3. For backward compatibility of ext-binary format, we take one bit from
ProfSummaryFlag as illustrated in the enum class `SecProfSummaryFlags`.
The ext-binary profile reader parses the integer type flag and reads
this bit. If it's set, the profile reader will parse vtable profiles.
4. The vtable profiles are optional in ext-binary format, and not
serialized out by default, we introduce an LLVM boolean option (named
`-extbinary-write-vtable-type-prof`). The ext-binary profile writer
reads the boolean option and decide whether to set the section flag bit
and serialize the in-memory class members corresponding to vtables.
5. This change doesn't implement `llvm-profdata overlap --sample` for
the vtable profiles. A subsequent change will do it to keep this one
focused on the profile format change.

We don't plan to add the vtable support to non-extensible format mainly
because of the maintenance cost to keep backward compatibility for prior
versions of profile data.
* Currently, the [non-extensible binary
format](https://github.com/llvm/llvm-project/blob/5c28af409978c19a35021855a29dcaa65e95da00/llvm/lib/ProfileData/SampleProfWriter.cpp#L899-L900)
does not have feature parity with extensible binary format today, for
instance, the former doesn't support [profile symbol
list](https://github.com/llvm/llvm-project/blob/41e22aa31b1905aa3e9d83c0343a96ec0d5187ec/llvm/include/llvm/ProfileData/SampleProf.h#L1518-L1522)
or context-sensitive PGO, both of which give measurable performance
boost. Presumably the non-extensible format is not in wide use.

---------

Co-authored-by: Paschalis Mpeis &lt;paschalis.mpeis@arm.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This change extends SampleFDO ext-binary and text format to record the
vtable symbols and their counts for virtual calls inside a function. The
vtable profiles will allow the compiler to annotate vtable types on IR
instructions and perform vtable-based indirect call promotion. An RFC is
in
https://discourse.llvm.org/t/rfc-vtable-type-profiling-for-samplefdo/87283

Given a function below, the before vs after of a function's profile is
illustrated in text format in the table:

```
__attribute__((noinline)) int loop_func(int i, int a, int b) {
    Base *ptr = createType(i);

    int sum = ptr-&gt;func(a, b);
    
    delete ptr;
    
    return sum;
}
```

| before | after |
| --- | --- |
| Samples collected in the function's body { &lt;br&gt; 0: 636241 &lt;br&gt; 1:
681458, calls: _Z10createTypei:681458 &lt;br&gt; 3: 543499, calls:
_ZN12_GLOBAL__N_18Derived24funcEii:410621 _ZN8Derived14funcEii:132878
&lt;br&gt; 5.1: 602201, calls: _ZN12_GLOBAL__N_18Derived2D0Ev:454635
_ZN8Derived1D0Ev:147566 &lt;br&gt; 7: 511057 &lt;br&gt; } | Samples collected in the
function's body { &lt;br&gt; 0: 636241 &lt;br&gt; 1: 681458, calls:
_Z10createTypei:681458 &lt;br&gt; 3: 543499, calls:
_ZN12_GLOBAL__N_18Derived24funcEii:410621 _ZN8Derived14funcEii:132878
&lt;br&gt; 3: vtables: _ZTV8Derived1:1377 _ZTVN12_GLOBAL__N_18Derived2E:4250
&lt;br&gt; 5.1: 602201, calls: _ZN12_GLOBAL__N_18Derived2D0Ev:454635
_ZN8Derived1D0Ev:147566 &lt;br&gt; 5.1: vtables: _ZTV8Derived1:227
_ZTVN12_GLOBAL__N_18Derived2E:765 &lt;br&gt; 7: 511057 &lt;br&gt; } |

Key points for this change:
1. In-memory representation of vtable profiles
* A field of type `map&lt;LineLocation, map&lt;FunctionId, uint64_t&gt;&gt;` is
introduced in a function's in-memory representation
[FunctionSamples](https://github.com/llvm/llvm-project/blob/ccc416312ed72e92a885425d9cb9c01f9afa58eb/llvm/include/llvm/ProfileData/SampleProf.h#L749-L754).
2. The vtable counters for one LineLocation represents the relative
frequency among vtables for this LineLocation. They are not required to
be comparable across LineLocations.
3. For backward compatibility of ext-binary format, we take one bit from
ProfSummaryFlag as illustrated in the enum class `SecProfSummaryFlags`.
The ext-binary profile reader parses the integer type flag and reads
this bit. If it's set, the profile reader will parse vtable profiles.
4. The vtable profiles are optional in ext-binary format, and not
serialized out by default, we introduce an LLVM boolean option (named
`-extbinary-write-vtable-type-prof`). The ext-binary profile writer
reads the boolean option and decide whether to set the section flag bit
and serialize the in-memory class members corresponding to vtables.
5. This change doesn't implement `llvm-profdata overlap --sample` for
the vtable profiles. A subsequent change will do it to keep this one
focused on the profile format change.

We don't plan to add the vtable support to non-extensible format mainly
because of the maintenance cost to keep backward compatibility for prior
versions of profile data.
* Currently, the [non-extensible binary
format](https://github.com/llvm/llvm-project/blob/5c28af409978c19a35021855a29dcaa65e95da00/llvm/lib/ProfileData/SampleProfWriter.cpp#L899-L900)
does not have feature parity with extensible binary format today, for
instance, the former doesn't support [profile symbol
list](https://github.com/llvm/llvm-project/blob/41e22aa31b1905aa3e9d83c0343a96ec0d5187ec/llvm/include/llvm/ProfileData/SampleProf.h#L1518-L1522)
or context-sensitive PGO, both of which give measurable performance
boost. Presumably the non-extensible format is not in wide use.

---------

Co-authored-by: Paschalis Mpeis &lt;paschalis.mpeis@arm.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>[NFC][SampleFDO] Re-apply "In text sample prof reader, report more concrete parsing errors for different line types" (#155124)</title>
<updated>2025-08-24T00:49:11+00:00</updated>
<author>
<name>Mingming Liu</name>
<email>mingmingl@google.com</email>
</author>
<published>2025-08-24T00:49:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=c987950fad8d80182705673b404e4b151669ddff'/>
<id>c987950fad8d80182705673b404e4b151669ddff</id>
<content type='text'>
Re-apply https://github.com/llvm/llvm-project/pull/154885 with a fix to initialize `LineTy` before calling `ParseLine`.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Re-apply https://github.com/llvm/llvm-project/pull/154885 with a fix to initialize `LineTy` before calling `ParseLine`.</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "[NFC][SampleFDO] In text sample prof reader, report dreport more concrete parsing errors for different line types" (#155121)</title>
<updated>2025-08-23T21:43:55+00:00</updated>
<author>
<name>Mingming Liu</name>
<email>mingmingl@google.com</email>
</author>
<published>2025-08-23T21:43:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=ebac9f4338592dbf83767ff229e6f219c73bb6b9'/>
<id>ebac9f4338592dbf83767ff229e6f219c73bb6b9</id>
<content type='text'>
Reverts llvm/llvm-project#154885 to fix build bot failure
(https://lab.llvm.org/buildbot/#/builders/144/builds/33611)</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Reverts llvm/llvm-project#154885 to fix build bot failure
(https://lab.llvm.org/buildbot/#/builders/144/builds/33611)</pre>
</div>
</content>
</entry>
<entry>
<title>[NFC][SampleFDO] In text sample prof reader, report dreport more concrete parsing errors for different line types (#154885)</title>
<updated>2025-08-23T21:37:13+00:00</updated>
<author>
<name>Mingming Liu</name>
<email>mingmingl@google.com</email>
</author>
<published>2025-08-23T21:37:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=52b0e3f1ccd81198f285a4e90558ed2015dc1db3'/>
<id>52b0e3f1ccd81198f285a4e90558ed2015dc1db3</id>
<content type='text'>
The format `'NUM[.NUM]: NUM[ mangled_name:NUM]*'` applies for most line
types except metadata ones.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The format `'NUM[.NUM]: NUM[ mangled_name:NUM]*'` applies for most line
types except metadata ones.</pre>
</div>
</content>
</entry>
<entry>
<title>[ProfileData] Remove an unnecessary cast (NFC) (#148341)</title>
<updated>2025-07-12T18:28:48+00:00</updated>
<author>
<name>Kazu Hirata</name>
<email>kazu@google.com</email>
</author>
<published>2025-07-12T18:28:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=854cce2d0a3c695e024b5ba83ab747919710b7a8'/>
<id>854cce2d0a3c695e024b5ba83ab747919710b7a8</id>
<content type='text'>
getBufferStart() already returns const char *.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
getBufferStart() already returns const char *.</pre>
</div>
</content>
</entry>
<entry>
<title>[NFC]Codestyle changes for SampleFDO library (#147840)</title>
<updated>2025-07-09T23:48:17+00:00</updated>
<author>
<name>Mingming Liu</name>
<email>mingmingl@google.com</email>
</author>
<published>2025-07-09T23:48:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=20daa73a0962efd22cee3bbf327ee35b22add39d'/>
<id>20daa73a0962efd22cee3bbf327ee35b22add39d</id>
<content type='text'>
* Introduce an error code for illegal_line_offset in sampleprof_error
namespace, and use it for line offset parsing error.
* Add `const` for `LineLocation::serialize`.
* Use structured binding, make_first/second_range in loops.

I'm working on a [sample-profile format
change](https://github.com/llvm/llvm-project/compare/users/mingmingl-llvm/samplefdo-profile-format)
to extend SampleFDO profile with vtable profiles. And this change splits
the non-functional changes.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Introduce an error code for illegal_line_offset in sampleprof_error
namespace, and use it for line offset parsing error.
* Add `const` for `LineLocation::serialize`.
* Use structured binding, make_first/second_range in loops.

I'm working on a [sample-profile format
change](https://github.com/llvm/llvm-project/compare/users/mingmingl-llvm/samplefdo-profile-format)
to extend SampleFDO profile with vtable profiles. And this change splits
the non-functional changes.</pre>
</div>
</content>
</entry>
<entry>
<title>[NFCI] Clean up idempotent stack pop for inline context (#141544)</title>
<updated>2025-05-27T16:41:54+00:00</updated>
<author>
<name>Mingming Liu</name>
<email>mingmingl@google.com</email>
</author>
<published>2025-05-27T16:41:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=eb79e340a10fd0292c7fa2e3ca05895b8402f29e'/>
<id>eb79e340a10fd0292c7fa2e3ca05895b8402f29e</id>
<content type='text'>
In the top-of-tree, the stack pops at L414-416 [1] are no-op since there
are prior stack pops at L400-402.

[1]
https://github.com/llvm/llvm-project/blame/e015626f189dc76f8df9fdc25a47638c6a2f3feb/llvm/lib/ProfileData/SampleProfReader.cpp#L414-L416
[2]
https://github.com/llvm/llvm-project/blame/e015626f189dc76f8df9fdc25a47638c6a2f3feb/llvm/lib/ProfileData/SampleProfReader.cpp#L400-L402</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In the top-of-tree, the stack pops at L414-416 [1] are no-op since there
are prior stack pops at L400-402.

[1]
https://github.com/llvm/llvm-project/blame/e015626f189dc76f8df9fdc25a47638c6a2f3feb/llvm/lib/ProfileData/SampleProfReader.cpp#L414-L416
[2]
https://github.com/llvm/llvm-project/blame/e015626f189dc76f8df9fdc25a47638c6a2f3feb/llvm/lib/ProfileData/SampleProfReader.cpp#L400-L402</pre>
</div>
</content>
</entry>
<entry>
<title>Clean up external users of GlobalValue::getGUID(StringRef) (#129644)</title>
<updated>2025-04-28T01:09:43+00:00</updated>
<author>
<name>Owen Rodley</name>
<email>orodley@google.com</email>
</author>
<published>2025-04-28T01:09:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=d3d856ad84698fa4ec66177d00558b2f5b438d3b'/>
<id>d3d856ad84698fa4ec66177d00558b2f5b438d3b</id>
<content type='text'>
See https://discourse.llvm.org/t/rfc-keep-globalvalue-guids-stable/84801
for context.

This is a non-functional change which just changes the interface of
GlobalValue, in preparation for future functional changes. This part
touches a fair few users, so is split out for ease of review. Future
changes to the GlobalValue implementation can then be focused purely on
that class.

This does the following:

* Rename GlobalValue::getGUID(StringRef) to
  getGUIDAssumingExternalLinkage. This is simply making explicit at the
  callsite what is currently implicit.
* Where possible, migrate users to directly calling getGUID on a
  GlobalValue instance.
* Otherwise, where possible, have them call the newly renamed
  getGUIDAssumingExternalLinkage, to make the assumption explicit.


There are a few cases where neither of the above are possible, as the
caller saves and reconstructs the necessary information to compute the
GUID themselves. We want to migrate these callers eventually, but for
this first step we leave them be.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
See https://discourse.llvm.org/t/rfc-keep-globalvalue-guids-stable/84801
for context.

This is a non-functional change which just changes the interface of
GlobalValue, in preparation for future functional changes. This part
touches a fair few users, so is split out for ease of review. Future
changes to the GlobalValue implementation can then be focused purely on
that class.

This does the following:

* Rename GlobalValue::getGUID(StringRef) to
  getGUIDAssumingExternalLinkage. This is simply making explicit at the
  callsite what is currently implicit.
* Where possible, migrate users to directly calling getGUID on a
  GlobalValue instance.
* Otherwise, where possible, have them call the newly renamed
  getGUIDAssumingExternalLinkage, to make the assumption explicit.


There are a few cases where neither of the above are possible, as the
caller saves and reconstructs the necessary information to compute the
GUID themselves. We want to migrate these callers eventually, but for
this first step we leave them be.</pre>
</div>
</content>
</entry>
<entry>
<title>[CSSPGO] Fix redundant reading of profile metadata (#129609)</title>
<updated>2025-03-04T19:39:59+00:00</updated>
<author>
<name>Lei Wang</name>
<email>wlei@fb.com</email>
</author>
<published>2025-03-04T19:39:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=d38380d3d808183652c1e9be34e3a2476ed6ea70'/>
<id>d38380d3d808183652c1e9be34e3a2476ed6ea70</id>
<content type='text'>
Fix a build speed regression due to repeated reading of profile
metadata. Before the function `readFuncMetadata(ProfileHasAttribute,
Profiles)` reads the metadata for all the functions(`Profiles`),
however, it's actually used for on-demand loading, it can be called for
multiple times, which leads to redundant reading that causes the build
speed regression. Now fix it to read the metadata only for the new
loaded functions(functions in the `FuncsToUse`).</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fix a build speed regression due to repeated reading of profile
metadata. Before the function `readFuncMetadata(ProfileHasAttribute,
Profiles)` reads the metadata for all the functions(`Profiles`),
however, it's actually used for on-demand loading, it can be called for
multiple times, which leads to redundant reading that causes the build
speed regression. Now fix it to read the metadata only for the new
loaded functions(functions in the `FuncsToUse`).</pre>
</div>
</content>
</entry>
</feed>
