[llvm] [LICM] Prevent LICM of ptrtoint and inttoptr when using non-integral pointers (PR #97272)

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 15 22:49:38 PDT 2024


=?utf-8?q?Csanád_Hajdú?= <csanad.hajdu at arm.com>,
=?utf-8?q?Csanád_Hajdú?= <csanad.hajdu at arm.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/97272 at github.com>


arpilipe wrote:

Here is how we implement fencing: Operations that inspect the bitwise representation of GC pointers are wrapped into function calls. These calls remain opaque to the optimizer until they are inlined. We inline them only after we have inserted explicit relocations using RewriteStatepointsForGC. Once the relocations are explicit, statepoints act as barriers to optimizations.

For example, in your case, if a loop contains a statepoint, the corresponding relocation will create a new def for the value, preventing LICM.

Restricting the hoisting of inttoptr and ptrtoint for non-integral pointers will prevent hoisting in cases where the appropriate fencing has been done. E.g., in our scenario, hoisting is possible after RewriteStatepointsForGC if the loop doesn't contain statepoints, thus can't change the bitwise representation of the pointers.

I'm not sure if this has a significant performance impact, so I don't have a strong preference. However, before we restrict the optimization, you may consider a similar fencing scheme to prevent undesirable transformations.

https://github.com/llvm/llvm-project/pull/97272


More information about the llvm-commits mailing list