[PATCH] D93927: [ArgPromotion] Copy !range metadata for loads.
Chenguang Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 26 17:45:00 PDT 2021
wecing added a comment.
> We were already transfering the AA metadata, which is also incorrect.
IIUC, lack of AA metadata wouldn't result in incorrect code, so that SGTM. But for this:
> And we were transferring the load alignment (this probably shouldn't be transferred at all but rather a precondition)
I have an counterexample:
int func(int *p) {
if (p % 4 != 0) {
return load(p, align=1);
}
return 0;
}
>From LLVM lang ref <https://llvm.org/docs/LangRef.html#load-instruction>:
> an omitted align argument means that the operation has the ABI alignment for the target... Overestimating the alignment results in undefined behavior... An alignment of 1 is always safe.
Not copying the `align` info should cause LLVM to fall back to `load align 4`, but since `p % 4 != 0`, it would produce undefined behavior.
So my guess is we should always copy `align` and `!align`; for the rest metadata items, as you suggested, only copy if they are guaranteed to be executed.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93927/new/
https://reviews.llvm.org/D93927
More information about the llvm-commits
mailing list