[PATCH] D83082: [Alignment][NFC] Use proper getter to retrieve alignment from ConstantInt and ConstantSDNode
Jessica Clarke via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 5 16:00:23 PDT 2020
jrtc27 added a comment.
In D83082#2131971 <https://reviews.llvm.org/D83082#2131971>, @sbc100 wrote:
> This change seems to have broken one of our tests in emscripten. I reduced it to this:
>
> #include <stdlib.h>
> #include <assert.h>
>
> int main() {
> void * ptr = aligned_alloc(3, 64);
> assert(ptr == NULL);
> return 0;
> }
>
Yeah, this is testing DR 460's new (and accepted) requirements (previously it was undefined):
> If the value of alignment is not a valid alignment supported by the implementation or the value of size is not an integral multiple of alignment the function shall fail by returning a null pointer.
I feel this should probably be handled specially (ie use align(1) or no alignment) in the Clang frontend? Though I wouldn't like to say how things change when you change it to:
int align = 3;
void *ptr = aligned_alloc(align, 64);
For sufficiently obfuscated code I can imagine Clang not noticing but a later LLVM pass discovering the alignment is a constant and trying to set the attributes up as such.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83082/new/
https://reviews.llvm.org/D83082
More information about the llvm-commits
mailing list