[PATCH] D71521: Support for library function aligned_alloc

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 15 21:24:38 PST 2019


jdoerfert added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp:4300
+                      Attribute::getWithDereferenceableOrNullBytes(
+                          Call.getContext(), Op1C->getZExtValue()));
   } else if (isReallocLikeFn(&Call, TLI) && Op1C) {
----------------
bondhugula wrote:
> jdoerfert wrote:
> > If the alignment is constant we should add a align attribute as well.
> Actually, it need not be! :-) The alignment with the aligned_alloc call can be dynamic - it's just that we convert it to a stack allocation only when it's constant.
> Actually, it need not be! :-) The alignment with the aligned_alloc call can be dynamic - it's just that we convert it to a stack allocation only when it's constant.

I am aware.

Please read my comment as:
  For the cases where the alignment is a constant, which we can determine here since we are looking at the actual call, we should ...

I was not expecting this to be ambiguous given that the code you added will also only trigger if the size is a constant. Same thing, but with alignment is missing. 


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

https://reviews.llvm.org/D71521





More information about the llvm-commits mailing list