<feed xmlns='http://www.w3.org/2005/Atom'>
<title>llvm-project.git/llvm/lib/Transforms/Utils/CallPromotionUtils.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>[NFC][DebugInfo] Use iterator moveBefore at many call-sites (#123583)</title>
<updated>2025-01-24T10:53:11+00:00</updated>
<author>
<name>Jeremy Morse</name>
<email>jeremy.morse@sony.com</email>
</author>
<published>2025-01-24T10:53:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=8e702735090388a3231a863e343f880d0f96fecb'/>
<id>8e702735090388a3231a863e343f880d0f96fecb</id>
<content type='text'>
As part of the "RemoveDIs" project, BasicBlock::iterator now carries a
debug-info bit that's needed when getFirstNonPHI and similar feed into
instruction insertion positions. Call-sites where that's necessary were
updated a year ago; but to ensure some type safety however, we'd like to
have all calls to moveBefore use iterators.

This patch adds a (guaranteed dereferenceable) iterator-taking
moveBefore, and changes a bunch of call-sites where it's obviously safe
to change to use it by just calling getIterator() on an instruction
pointer. A follow-up patch will contain less-obviously-safe changes.

We'll eventually deprecate and remove the instruction-pointer
insertBefore, but not before adding concise documentation of what
considerations are needed (very few).</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As part of the "RemoveDIs" project, BasicBlock::iterator now carries a
debug-info bit that's needed when getFirstNonPHI and similar feed into
instruction insertion positions. Call-sites where that's necessary were
updated a year ago; but to ensure some type safety however, we'd like to
have all calls to moveBefore use iterators.

This patch adds a (guaranteed dereferenceable) iterator-taking
moveBefore, and changes a bunch of call-sites where it's obviously safe
to change to use it by just calling getIterator() on an instruction
pointer. A follow-up patch will contain less-obviously-safe changes.

We'll eventually deprecate and remove the instruction-pointer
insertBefore, but not before adding concise documentation of what
considerations are needed (very few).</pre>
</div>
</content>
</entry>
<entry>
<title>CallPromotionUtils: Correctly use IndexSize when determining the bit width of pointer offsets. (#119483)</title>
<updated>2024-12-11T03:49:48+00:00</updated>
<author>
<name>Owen Anderson</name>
<email>resistor@mac.com</email>
</author>
<published>2024-12-11T03:49:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=ab15976173e45fd02eb61e922a95ad1f5127c9a0'/>
<id>ab15976173e45fd02eb61e922a95ad1f5127c9a0</id>
<content type='text'>
This reapplies #119138 with a defensive fix for the assertion failure
when building libcxx.
Unfortunately the failure does not reproduce on my machine, so I am not
able to extract a test case.

The key insight for the fix comes from Jessica Clarke, who observes that
`VTablePtr` may, in fact,
not be a pointer on return from `FindAvailableLoadedValue`.

Co-authored-by: Alexander Richardson &lt;alexander.richardson@cl.cam.ac.uk&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reapplies #119138 with a defensive fix for the assertion failure
when building libcxx.
Unfortunately the failure does not reproduce on my machine, so I am not
able to extract a test case.

The key insight for the fix comes from Jessica Clarke, who observes that
`VTablePtr` may, in fact,
not be a pointer on return from `FindAvailableLoadedValue`.

Co-authored-by: Alexander Richardson &lt;alexander.richardson@cl.cam.ac.uk&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "CallPromotionUtils: Correctly use IndexSize when determining the bit width of pointer offsets. (#119138)"</title>
<updated>2024-12-11T00:20:17+00:00</updated>
<author>
<name>Owen Anderson</name>
<email>resistor@mac.com</email>
</author>
<published>2024-12-11T00:20:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=9b6bb8386001a1d308cda42fe273733e58b8e93e'/>
<id>9b6bb8386001a1d308cda42fe273733e58b8e93e</id>
<content type='text'>
Reverting due to ASAN bootstrap failures.

This reverts commit 4027e2f248044d944aaf3d9bc9c8eb6928506d44.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Reverting due to ASAN bootstrap failures.

This reverts commit 4027e2f248044d944aaf3d9bc9c8eb6928506d44.
</pre>
</div>
</content>
</entry>
<entry>
<title>CallPromotionUtils: Correctly use IndexSize when determining the bit width of pointer offsets. (#119138)</title>
<updated>2024-12-10T23:43:40+00:00</updated>
<author>
<name>Owen Anderson</name>
<email>resistor@mac.com</email>
</author>
<published>2024-12-10T23:43:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=4027e2f248044d944aaf3d9bc9c8eb6928506d44'/>
<id>4027e2f248044d944aaf3d9bc9c8eb6928506d44</id>
<content type='text'>
Co-authored-by: Alexander Richardson &lt;alexander.richardson@cl.cam.ac.uk&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Co-authored-by: Alexander Richardson &lt;alexander.richardson@cl.cam.ac.uk&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>[SimplifyLibCall][Attribute] Fix bug where we may keep `range` attr with incompatible type (#112649)</title>
<updated>2024-10-17T15:32:55+00:00</updated>
<author>
<name>goldsteinn</name>
<email>35538541+goldsteinn@users.noreply.github.com</email>
</author>
<published>2024-10-17T15:32:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=c85611e8583e6392d56075ebdfa60893b6284813'/>
<id>c85611e8583e6392d56075ebdfa60893b6284813</id>
<content type='text'>
In a variety of places we change the bitwidth of a parameter but don't
update the attributes.

The issue in this case is from the `range` attribute when inlining
`__memset_chk`. `optimizeMemSetChk` will replace an `i32` with an
`i8`, and if the `i32` had a `range` attr assosiated it will cause an
error.

Fixes #112633</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In a variety of places we change the bitwidth of a parameter but don't
update the attributes.

The issue in this case is from the `range` attribute when inlining
`__memset_chk`. `optimizeMemSetChk` will replace an `i32` with an
`i8`, and if the `i32` had a `range` attr assosiated it will cause an
error.

Fixes #112633</pre>
</div>
</content>
</entry>
<entry>
<title>[nfc][ctx_prof] Efficient profile traversal and update (#110052)</title>
<updated>2024-09-27T15:09:10+00:00</updated>
<author>
<name>Mircea Trofin</name>
<email>mtrofin@google.com</email>
</author>
<published>2024-09-27T15:09:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=c4952e513f845a0e290d22ed1131d1b6438bb65b'/>
<id>c4952e513f845a0e290d22ed1131d1b6438bb65b</id>
<content type='text'>
This optimizes profile updates and visits, where we want to access contexts for a specific function. These are all the current update cases. We do so by maintaining a list of contexts for each function, preserving preorder traversal. The list is updated whenever contexts are `std::move`-d or deleted.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This optimizes profile updates and visits, where we want to access contexts for a specific function. These are all the current update cases. We do so by maintaining a list of contexts for each function, preserving preorder traversal. The list is updated whenever contexts are `std::move`-d or deleted.</pre>
</div>
</content>
</entry>
<entry>
<title>[ctx_prof] Simple ICP criteria during module inliner (#109881)</title>
<updated>2024-09-25T22:05:52+00:00</updated>
<author>
<name>Mircea Trofin</name>
<email>mtrofin@google.com</email>
</author>
<published>2024-09-25T22:05:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=c8365feed7af6d17cd2cc04cdc7fe0247f87e9c8'/>
<id>c8365feed7af6d17cd2cc04cdc7fe0247f87e9c8</id>
<content type='text'>
This is mostly for test: under contextual profiling, we perform ICP for those indirect callsites which have targets marked as `alwaysinline`.

This helped uncover a bug with the way the profile was updated upon ICP, where we were skipping over the update if the target wasn't called in that context. That was resulting in incorrect counts for the indirect BB.

Also flyby fix to the total/direct count values, they should be 64-bit (as all counters are in the contextual profile)</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is mostly for test: under contextual profiling, we perform ICP for those indirect callsites which have targets marked as `alwaysinline`.

This helped uncover a bug with the way the profile was updated upon ICP, where we were skipping over the update if the target wasn't called in that context. That was resulting in incorrect counts for the indirect BB.

Also flyby fix to the total/direct count values, they should be 64-bit (as all counters are in the contextual profile)</pre>
</div>
</content>
</entry>
<entry>
<title>[ctx_prof] Add support for ICP (#105469)</title>
<updated>2024-08-27T22:50:13+00:00</updated>
<author>
<name>Mircea Trofin</name>
<email>mtrofin@google.com</email>
</author>
<published>2024-08-27T22:50:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=73c3b7337b0a3a8cb447f9801341d5648aebe9b2'/>
<id>73c3b7337b0a3a8cb447f9801341d5648aebe9b2</id>
<content type='text'>
An overload of `llvm::promoteCallWithIfThenElse` that updates the contextual profile.

High-level, this is very simple: after creating the `if... then (direct call) else (indirect call)` structure, we instrument the new callsites and BBs (the instrumentation will help with tracking for other IPO transformations, and, ultimately, to match counter values before flattening to `MD_prof`).

In more detail:

- move the callsite instrumentation of the indirect call to the `else` BB, before the indirect call
- create a new callsite instrumentation for the direct call
- create instrumentation for both the `then` and `else` BBs - we could instrument just one (MST-style) but we're not running the binary with this instrumentation, and at most this would save some space (less counters tracked). For simplicity instrumenting both at this point
- update each context belonging to the caller by updating the counters, and moving the indirect callee to the new, direct callsite ID

Issue #89287</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
An overload of `llvm::promoteCallWithIfThenElse` that updates the contextual profile.

High-level, this is very simple: after creating the `if... then (direct call) else (indirect call)` structure, we instrument the new callsites and BBs (the instrumentation will help with tracking for other IPO transformations, and, ultimately, to match counter values before flattening to `MD_prof`).

In more detail:

- move the callsite instrumentation of the indirect call to the `else` BB, before the indirect call
- create a new callsite instrumentation for the direct call
- create instrumentation for both the `then` and `else` BBs - we could instrument just one (MST-style) but we're not running the binary with this instrumentation, and at most this would save some space (less counters tracked). For simplicity instrumenting both at this point
- update each context belonging to the caller by updating the counters, and moving the indirect callee to the new, direct callsite ID

Issue #89287</pre>
</div>
</content>
</entry>
<entry>
<title>[IRBuilder] Don't include Module.h (NFC) (#97159)</title>
<updated>2024-06-29T13:05:04+00:00</updated>
<author>
<name>Nikita Popov</name>
<email>llvm@npopov.com</email>
</author>
<published>2024-06-29T13:05:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=74deadf19650f6f3b6392ba09caa20dd38ae41e0'/>
<id>74deadf19650f6f3b6392ba09caa20dd38ae41e0</id>
<content type='text'>
This used to be necessary to fetch the DataLayout, but isn't anymore.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This used to be necessary to fetch the DataLayout, but isn't anymore.</pre>
</div>
</content>
</entry>
<entry>
<title>[IR] Add getDataLayout() helpers to Function and GlobalValue (#96919)</title>
<updated>2024-06-28T06:36:49+00:00</updated>
<author>
<name>Nikita Popov</name>
<email>npopov@redhat.com</email>
</author>
<published>2024-06-28T06:36:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/llvm-project.git/commit/?id=9df71d7673b5c98e1032d01be83724a45b42fafc'/>
<id>9df71d7673b5c98e1032d01be83724a45b42fafc</id>
<content type='text'>
Similar to https://github.com/llvm/llvm-project/pull/96902, this adds
`getDataLayout()` helpers to Function and GlobalValue, replacing the
current `getParent()-&gt;getDataLayout()` pattern.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Similar to https://github.com/llvm/llvm-project/pull/96902, this adds
`getDataLayout()` helpers to Function and GlobalValue, replacing the
current `getParent()-&gt;getDataLayout()` pattern.</pre>
</div>
</content>
</entry>
</feed>
