[PATCH] D99791: [CGCall] Annotate pointer argument with alignment

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 2 02:05:04 PDT 2021


lebedev.ri created this revision.
lebedev.ri added reviewers: efriedma, rjmccall, rsmith, erichkeane, aaron.ballman, nikic.
lebedev.ri added a project: LLVM.
lebedev.ri requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Same idea as D99790 <https://reviews.llvm.org/D99790>.

As it is being noted in D99249 <https://reviews.llvm.org/D99249>, lack of alignment information on this has been preventing LICM from happening.
For some time now, lack of alignment attribute does *not* imply natural alignment, but an alignment of 1.

This causes quite a bit of clang tests to tail:

  Testing Time: 167.48s
    Unsupported      :    69
    Passed           : 27038
    Expectedly Failed:    29
    Failed           :   370
  FAILED: tools/clang/test/CMakeFiles/check-clang 

so before i go mad updating each one of them,
is this generally correct, or are we not allowed to do this?
Are there some further preconditions missing?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99791

Files:
  clang/lib/CodeGen/CGCall.cpp


Index: clang/lib/CodeGen/CGCall.cpp
===================================================================
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2445,6 +2445,15 @@
       }
     }
 
+    if (const auto *PtrTy = ParamType->getAs<PointerType>()) {
+      QualType PTy = PtrTy->getPointeeType();
+      if (PTy->isObjectType()) {
+        llvm::Align Alignment =
+            getNaturalPointeeTypeAlignment(ParamType).getAsAlign();
+        Attrs.addAlignmentAttr(Alignment);
+      }
+    }
+
     switch (FI.getExtParameterInfo(ArgNo).getABI()) {
     case ParameterABI::Ordinary:
       break;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99791.334923.patch
Type: text/x-patch
Size: 623 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210402/094fe362/attachment.bin>


More information about the cfe-commits mailing list