[PATCH] D76971: Deduce attributes for aligned_alloc in InstCombine

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 28 00:32:27 PDT 2020


jdoerfert added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp:4445
+                      Attribute::getWithDereferenceableOrNullBytes(
+                          Call.getContext(), Op1C->getZExtValue()));
   } else if (isReallocLikeFn(&Call, TLI) && Op1C) {
----------------
bondhugula wrote:
> jdoerfert wrote:
> > When Op0C is set (regardless of Op1C), we can set the alignment attribute on the return value, can't we?
> Would it be correct to set the alignment attribute for 0 sized allocations?
> Would it be correct to set the alignment attribute for 0 sized allocations?

Not in general, but: `The function aligned_alloc() is the same as memalign(), except for the added restriction that size should be a multiple of alignment.` So for a non-zero alignment size need to be non-zero. Please correct me if I'm wrong though.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76971/new/

https://reviews.llvm.org/D76971





More information about the llvm-commits mailing list