fhahn wrote:
> Do you have a testcase that shows how this goes wrong without this change ?
I am not 100% if the type-based aliasing rules allow aliasing a union access
containing a float and a plain pointer to float, but I am thinking about
something like the below, where we remove the first store to `f`, even though
`f` may alias the union if the float is selected. Again, not sure if that's
100% within the C/C++ type-based aliasing rules, but it is what I could
construct easily.
Irrespective of this it should show how the TBAA tags for the load of `u`
incorrectly claims it is loading an int.
```
union U2 {
int d;
float f;
};
struct UnionMember2 {
int p;
U2 u;
};
void use(int, U2);
void copy12( UnionMember2 *a2, float *f) {
*f = 1.0;
UnionMember2 a1 = *a2;
int p = a1.p;
U2 u = a1.u;
*f = 2.0;
use(p, u);
}
```
https://clang.godbolt.org/z/Y6PPWEo69
https://github.com/llvm/llvm-project/pull/84370
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits