[llvm] [LICM] Prevent LICM of ptrtoint and inttoptr when using non-integral pointers (PR #97272)
Csanád Hajdú via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 1 00:51:55 PDT 2024
Il-Capitano wrote:
In my use case, the result of `ptrtoint` is used for indexing a GC card table. The issue was that during the loop's execution, the original pointer could get relocated, meaning that a different index would be needed for the card table marking potentially every iteration. However, LICM hoisted the `ptrtoint` outside of the loop, resulting in the same index being used every iteration, which caused an issue.
Looking at the discussion you linked, and the [wording in the Language Reference](https://llvm.org/docs/LangRef.html#nointptrtype), I guess my question is what is meant by *implementation defined fencing*? I assumed that having a call not marked with `"gc-leaf-function"` (or at least `memory(inaccessiblemem: write)` to allow it changing the environment state) in the execution path would have sufficed, but LICM (and maybe other optimizations?) doesn't respect that currently. Would this fencing rather be, that the `ptrtoint` should be replaced by an external function call in order to observe the pointer's bit representation at that particular program state?
https://github.com/llvm/llvm-project/pull/97272
More information about the llvm-commits
mailing list