[PATCH] D100879: [Clang] Propagate guaranteed alignment for malloc and others

Dávid Bolvanský via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 20 11:59:50 PDT 2021


xbolva00 added inline comments.


================
Comment at: clang/lib/CodeGen/CGCall.cpp:2060
+        case Builtin::BIstrndup:
+          RetAttrs.addAlignmentAttr(Context.getTargetInfo().getNewAlign() /
+                                    Context.getTargetInfo().getCharWidth());
----------------
lebedev.ri wrote:
> malloc != new
But the comment for the implementation of this value points on eg. gcc's docs:

https://clang.llvm.org/doxygen/Basic_2TargetInfo_8cpp_source.html line 67

   // From the glibc documentation, on GNU systems, malloc guarantees 16-byte
   // alignment on 64-bit systems and 8-byte alignment on 32-bit systems. See
   // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html.
   // This alignment guarantee also applies to Windows and Android. On Darwin,
   // the alignment is 16 bytes on both 64-bit and 32-bit systems.

So this value is correct to be used for malloc and friends IMHO.


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

https://reviews.llvm.org/D100879



More information about the cfe-commits mailing list