[PATCH] D147020: [AA] Add a tbaa-fence intrinsic.
David Goldblatt via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 30 15:02:57 PDT 2023
davidtgoldblatt added a comment.
Added a LangRef entry that I hope clarifies things.
In D147020#4232988 <https://reviews.llvm.org/D147020#4232988>, @jeroen.dobbelaere wrote:
> What exactly are the wanted semantics for such a fence ? And how would it be used ?
> Once a pointer is stored into memory, you loose the fence dependency and tbaa does not look into that.
>
> Assume following code:
>
> int bar (int *p, short *q) {
> *p =42;
> *q =99;
> return *p;
> }
> int foo(int * p) {
> short * q = (short *)tbaa_fence(p);
> return bar(p, q);
> }
>
> This will still return 42
The fence only applies between loads/stores before the fence and those based on its result (that is; in the newly written-down semantics that only existed in my head before now. Sorry, should have had documentation to start with). So, the optimization you're describing still being allowed matches those semantics. This is fine for the goal of letting us implement start_lifetime_as -- there's still C++-level UB when bar tries to read a short from an address that contains an int.
> Would we want to use this intrinsic as part of the code generation for C++ new expressions? See https://github.com/llvm/llvm-project/issues/54878 .
Hmm, I think this is a plausible fix but I'm not sufficiently confident in my understanding of all the subtleties of LICM to say for sure.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147020/new/
https://reviews.llvm.org/D147020
More information about the llvm-commits
mailing list