martinboehme wrote: > > In summary, if the storage locations for two pointers are the same, we can > > return a true literal for the comparison, but if the storage locations are > > different, we need to return an atom. > > I am wondering, if it would make sense to "fix up" the state when we discover > aliasing? I.e., "merging" the two storage locations. Consider: > > ``` > void f(MyBoolPair* a, MyBoolPair *b) { > if (a == b && a->first && !b->second) > { > // Here, we should know: a->first == b->first == true and a->second == > b->second == false > } > } > ```
This sounds great -- but I think getting this to work wouldn't be trivial. At least, I don't yet have any good ideas on how to make it work. I think we'd have to do something like this: 1. When we evaluate `a == b`, associate this expression with an atom, then remember that this atom means that the storage locations for the two pointers are the same. 2. When we enter a new block, if we can prove from the flow condition that the atom mentioned in step 1 is true, remember that the storage locations for `a` and `b` must alias. 3. When we evaluate `b->first` -- I guess we iterate over all of the storage locations that must alias with the storage location for `b`, and if, for at least one of them, we can prove that `b->first` is true, we know it must be true? (I'm not super-conversant in alias analysis -- would have to read up more about this.) Would require some more thought and definitely quite a bit of effort to implement, I think. https://github.com/llvm/llvm-project/pull/75170 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits