[PATCH] D37312: Add documentation for force_align_arg_pointer function attribute

Anatol Pomozov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 30 16:38:58 PDT 2017


anatol.pomozov updated this revision to Diff 113340.

https://reviews.llvm.org/D37312

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td


Index: include/clang/Basic/AttrDocs.td
===================================================================
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -2803,6 +2803,31 @@
   }];
 }
 
+def X86ForceAlignArgPointerDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Use this attribute to force stack alignment.
+
+Legacy x86 code uses 4-byte stack alignment. Newer aligned SSE instructions
+(like 'movaps') that work with stack require operands to be 16-byte aligned.
+This attribute realigns stack in the function prologue to make sure the stack
+can be used with SSE instructions.
+
+Note that the x86_64 ABI forces 16-byte stack alignment at the call site.
+Because of this, 'force_align_arg_pointer' is not needed at x86_64 except rare
+cases when caller does not align the stack correctly (e.g. flow jumps from i386
+arch code).
+
+  .. code-block:: c
+
+    __attribute__ ((force_align_arg_pointer))
+    void f () {
+      ...
+    }
+
+  }];
+}
+
 def SwiftCallDocs : Documentation {
   let Category = DocCatVariable;
   let Content = [{
Index: include/clang/Basic/Attr.td
===================================================================
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -2043,11 +2043,11 @@
 }
 
 def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetAnyX86> {
-  let Spellings = [GNU<"force_align_arg_pointer">];
+  let Spellings = [GCC<"force_align_arg_pointer">];
   // Technically, this appertains to a FunctionDecl, but the target-specific
   // code silently allows anything function-like (such as typedefs or function
   // pointers), but does not apply the attribute to them.
-  let Documentation = [Undocumented];
+  let Documentation = [X86ForceAlignArgPointerDocs];
 }
 
 def NoSanitize : InheritableAttr {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37312.113340.patch
Type: text/x-patch
Size: 1836 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170830/5f6985d4/attachment.bin>


More information about the cfe-commits mailing list