New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[InstCombine] bad combine for load inst caused by tbaa if two arguments ptr is same #68523
Comments
A more simple example https://godbolt.org/z/dWdcK3Ydh
After
Still, |
How is this not a strict aliasing violation? |
I'm not sure. I just assume based on the unexpected result. |
Tagging @AaronBallman to confirm whether this is a strict aliasing violation or not. |
This is add |
Hrm, I think something is definitely wrong here. For example, with:
nothing ends the lifetime of the I think it's also a strict aliasing violation because:
tries to start the lifetime of two different types at the same memory location without an intervening end lifetime. |
IMHO, check alias |
As explained above, your code exhibits undefined behavior. There is nothing to fix. If you want to opt-out of strict aliasing requirements, use the |
This code used C++ placement new https://en.cppreference.com/w/cpp/language/new . It allows apply diff type to same memory location. I don't know what's your point of undefined behavior. The undefined behavior is language rel or llvm compiler rel? |
The UB is in the language realm. Placement new starts the lifetime of an object at a particular memory location. You're starting the lifetime of multiple objects of different types at the same memory location. What happens if you try using |
Thx your patient. Now I know what is strict aliasing violation. |
The code run fail in
arm64be ilp32
inO2
level,https://godbolt.org/z/3rddjszhc
godbolt not support
ilp32
, I simpilify it useaarch64_be
in IR (hope yours can get the point :-) ).debug info like:
DSE
mergeto
Then,
alias
thinkstore i64 858993459400, ptr %c2, align 8, !tbaa !9
isNoAlias
to%c1
Loc (cause the size 4!=8 ???), so it combineto
But, in fact,
%c1
and%c2
is the sameptr
.The text was updated successfully, but these errors were encountered: