[PATCH] D76971: Deduce attributes for aligned_alloc in InstCombine

Uday Bondhugula via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 28 02:10:14 PDT 2020


bondhugula added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp:4445
+                      Attribute::getWithDereferenceableOrNullBytes(
+                          Call.getContext(), Op1C->getZExtValue()));
   } else if (isReallocLikeFn(&Call, TLI) && Op1C) {
----------------
jdoerfert wrote:
> 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.
The size could still be zero. (zero as size would be a multiple of any alignment. :-))


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