From: Erich Keane Date: Thu, 31 Aug 2017 21:08:24 +0000 (+0000) Subject: Add documentation for force_align_arg_pointer function attribute X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=349091162fcf2211a2e55cf81db934978e1c4f0c;p=clang Add documentation for force_align_arg_pointer function attribute Patch By: anatol.pomozov (anatol.pomozov@gmail.com) Differential Revision: https://reviews.llvm.org/D37312 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@312281 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td index 7cf307efc9..8b7eb93004 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td @@ -2043,11 +2043,11 @@ def AnyX86NoCallerSavedRegisters : InheritableAttr, } def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr { - 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 { diff --git a/include/clang/Basic/AttrDocs.td b/include/clang/Basic/AttrDocs.td index 96f7c45057..027c597c6e 100644 --- a/include/clang/Basic/AttrDocs.td +++ b/include/clang/Basic/AttrDocs.td @@ -2803,6 +2803,31 @@ For example: }]; } +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 the stack require operands to be 16-byte aligned. +This attribute realigns the 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 on x86_64, except in +rare cases where the caller does not align the stack properly (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 = [{