r196415 - This attribute somehow remained nameless in the attribute tablegen, until now.
Aaron Ballman
aaron at aaronballman.com
Fri Dec 6 05:36:16 PST 2013
On Fri, Dec 6, 2013 at 4:05 AM, Alexander Potapenko <glider at google.com> wrote:
> Maybe MSVC doesn't define __GNUC__? I guess it's better to remove the
> #ifdef clutter so that the attribute is applied unconditionally.
Even when I did that, I was unable to reproduce. A very basic test of:
__attribute__((__force_align_arg_pointer__))
void f(void);
Would not demonstrate the issue. When I stepped through the code, it
would get to getKind, strip off the leading and trailing underscores,
and determine the proper attribute id.
> The problem is reproducible for me and Kostya on our machines as well
> as on our build server (all of them running Linux)
I don't have access to a Linux box right now. Give me a bit to set one
up; any particular distro you are seeing this with? Also, x86 or x64
host environment?
In the meantime, does the following code work for you:
__attribute__((force_align_arg_pointer))
void f(void);
Or does it also emit the diagnostic?
Thanks!
~Aaron
>
> On Thu, Dec 5, 2013 at 9:22 PM, Aaron Ballman <aaron at aaronballman.com> wrote:
>> Thank you for bringing this to my attention. I may need some further
>> information on this, as I am not able to reproduce. The leading and
>> trailing underscores are stripped when determining the attribute kind
>> based off the name (you can see this in AttributeList.cpp:124), so I
>> would be surprised if this came up as an unknown attribute based on
>> the name. Perhaps this is a transient build issue for you, and a
>> rebuild solves it?
>>
>> I am testing with ToT (fetched this morning), built using MSVC 2013
>> for x86 and tested on Windows 7.
>>
>> ~Aaron
>>
>> On Thu, Dec 5, 2013 at 10:37 AM, Alexander Potapenko <glider at google.com> wrote:
>>> Hi Aaron,
>>>
>>> Clang now reports an unknown attribute for the following code (a
>>> slightly modified excerpt from Mozilla QCMS):
>>>
>>> $ bin/clang++ -c t.cc
>>> t.cc:14:16: warning: unknown attribute '__force_align_arg_pointer__'
>>> ignored [-Wattributes]
>>> __attribute__((__force_align_arg_pointer__))
>>> ^
>>>
>>>
>>> ==============================================================
>>> $ cat t.cc
>>> /* __force_align_arg_pointer__ is an x86-only attribute, and gcc/clang
>>> warns on unused
>>> * attributes. Don't use this on ARM or AMD64. __has_attribute can
>>> detect the presence
>>> * of the attribute but is currently only supported by clang */
>>> #if defined(__has_attribute)
>>> #define HAS_FORCE_ALIGN_ARG_POINTER __has_attribute(__force_align_arg_pointer__)
>>> #elif defined(__GNUC__) && !defined(__x86_64__) && !defined(__amd64__)
>>> && !defined(__arm__) && !defined(__mips__)
>>> #define HAS_FORCE_ALIGN_ARG_POINTER 1
>>> #else
>>> #define HAS_FORCE_ALIGN_ARG_POINTER 0
>>> #endif
>>>
>>> #if HAS_FORCE_ALIGN_ARG_POINTER
>>> /* we need this to avoid crashes when gcc assumes the stack is 128bit aligned */
>>> __attribute__((__force_align_arg_pointer__))
>>> #endif
>>> int foo() {
>>> return 0;
>>> }
>>> ==============================================================
>>>
>>> On Thu, Dec 5, 2013 at 1:43 AM, Aaron Ballman <aaron at aaronballman.com> wrote:
>>>> Author: aaronballman
>>>> Date: Wed Dec 4 15:43:30 2013
>>>> New Revision: 196415
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=196415&view=rev
>>>> Log:
>>>> This attribute somehow remained nameless in the attribute tablegen, until now.
>>>>
>>>> Modified:
>>>> cfe/trunk/include/clang/Basic/Attr.td
>>>> cfe/trunk/lib/Sema/TargetAttributesSema.cpp
>>>>
>>>> Modified: cfe/trunk/include/clang/Basic/Attr.td
>>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=196415&r1=196414&r2=196415&view=diff
>>>> ==============================================================================
>>>> --- cfe/trunk/include/clang/Basic/Attr.td (original)
>>>> +++ cfe/trunk/include/clang/Basic/Attr.td Wed Dec 4 15:43:30 2013
>>>> @@ -916,7 +916,10 @@ def WeakRef : InheritableAttr {
>>>> }
>>>>
>>>> def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr {
>>>> - let Spellings = [];
>>>> + let Spellings = [GNU<"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.
>>>> }
>>>>
>>>> // Attribute to disable AddressSanitizer (or equivalent) checks.
>>>>
>>>> Modified: cfe/trunk/lib/Sema/TargetAttributesSema.cpp
>>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TargetAttributesSema.cpp?rev=196415&r1=196414&r2=196415&view=diff
>>>> ==============================================================================
>>>> --- cfe/trunk/lib/Sema/TargetAttributesSema.cpp (original)
>>>> +++ cfe/trunk/lib/Sema/TargetAttributesSema.cpp Wed Dec 4 15:43:30 2013
>>>> @@ -267,8 +267,7 @@ namespace {
>>>> }
>>>> }
>>>> if (Triple.getArch() != llvm::Triple::x86_64 &&
>>>> - (Attr.getName()->getName() == "force_align_arg_pointer" ||
>>>> - Attr.getName()->getName() == "__force_align_arg_pointer__")) {
>>>> + Attr.getKind() == AttributeList::AT_X86ForceAlignArgPointer) {
>>>> HandleX86ForceAlignArgPointerAttr(D, Attr, S);
>>>> return true;
>>>> }
>>>>
>>>>
>>>> _______________________________________________
>>>> cfe-commits mailing list
>>>> cfe-commits at cs.uiuc.edu
>>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>>
>>>
>>>
>>> --
>>> Alexander Potapenko
>>> Software Engineer
>>> Google Moscow
>
>
>
> --
> Alexander Potapenko
> Software Engineer
> Google Moscow
More information about the cfe-commits
mailing list