[PATCH] D80166: [CGCall] Annotate reference parameters with "align" attribute.

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 19 11:28:45 PDT 2020


efriedma marked 2 inline comments as done.
efriedma added inline comments.


================
Comment at: clang/lib/CodeGen/CGCall.cpp:2116
+    if (PTy->isObjectType()) {
+      if (unsigned Alignment = getContext().getTypeAlignIfKnown(PTy))
+        RetAttrs.addAlignmentAttr(
----------------
rjmccall wrote:
> This doesn't do the right thing for classes with virtual bases.  There's a `getNaturalTypeAlignment` function you should be able to use, although you might have to pull it to CGM.
Good point; I'll fix it.


================
Comment at: clang/lib/CodeGen/CGCall.cpp:2258
         Attrs.addDereferenceableAttr(info.first.getQuantity());
-        Attrs.addAttribute(llvm::Attribute::getWithAlignment(
-            getLLVMContext(), info.second.getAsAlign()));
+        Attrs.addAlignmentAttr(info.second.getAsAlign());
       }
----------------
rjmccall wrote:
> Both of these are wrong for classes with virtual bases.
I'm pretty sure classes with virtual bases aren't used with SwiftIndirectResult, so not really relevant.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80166





More information about the cfe-commits mailing list