rjmccall added a comment.
Herald added a subscriber: sstefan1.

Hmm.  It looks like we did reserve space for this in the great 
pointer-alignment-assumption detente ("RFC: Enforcing pointer type alignment in 
Clang" from early 2016, which I'm aware was never really a consensus position, 
but which we've nonetheless been living by):

> But note that this rule does still allow the compiler to make stronger
>  abstract assumptions about the alignment of C++ references and the
>  "this" pointer.





================
Comment at: clang/lib/CodeGen/CGCall.cpp:2116
+    if (PTy->isObjectType()) {
+      if (unsigned Alignment = getContext().getTypeAlignIfKnown(PTy))
+        RetAttrs.addAlignmentAttr(
----------------
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.


================
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());
       }
----------------
Both of these are wrong for classes with virtual bases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80166



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to