[PATCH] align_value attribute in Clang

Hal Finkel hfinkel at anl.gov
Wed Sep 17 16:25:13 PDT 2014


----- Original Message -----
> From: "Hal Finkel" <hfinkel at anl.gov>
> To: reviews+D4635+public+b7e82bdc1d8c324a at reviews.llvm.org
> Cc: "a bataev" <a.bataev at hotmail.com>, "nurmukhametov alex" <nurmukhametov.alex at gmail.com>, "aaron ballman"
> <aaron.ballman at gmail.com>, richard at metafoo.co.uk, cfe-commits at cs.uiuc.edu
> Sent: Monday, September 8, 2014 6:59:07 PM
> Subject: Re: [PATCH] align_value attribute in Clang
> 
> ----- Original Message -----
> > From: hfinkel at anl.gov
> > To: hfinkel at anl.gov, "aaron ballman" <aaron.ballman at gmail.com>,
> > bigcheesegs at gmail.com, richard at metafoo.co.uk, "a
> > bataev" <a.bataev at hotmail.com>
> > Cc: cfe-commits at cs.uiuc.edu, "nurmukhametov alex"
> > <nurmukhametov.alex at gmail.com>
> > Sent: Monday, September 8, 2014 6:38:44 PM
> > Subject: Re: [PATCH] align_value attribute in Clang
> > 
> > Rebased, and removed from inappropriate
> > isTypeDependent/isValueDependent checks (inappropriate here for the
> > same reason they were inappropriate in patch D4601 for the
> > assume_aligned attribute).
> > 
> > Work still needs to be done to allow use as a type attribute (so
> > that
> > the attribute follows type deduction, auto, etc.). I'll send a
> > follow-up e-mail about this with questions.

Pinging re: the design question below.

Thanks again,
Hal

> 
> I need this attribute to follow type deduction (auto, etc.), and as
> we've discussed, just making this a declaration attribute does not
> seem to do this. It seems to me that what I need to do, or at least
> might do, is hook align_value into AttributedType, and handle it in
> lib/Sema/SemaType.cpp. First, it is not clear where I should store
> the alignment parameter:
>   - address_space stores its value in the type qualifiers
>   - reg_parm stores its value as part of FunctionType
>   - vector_type / ext_vector_type are their own Type subclasses
>   (where ExtVectorType is a subclass of VectorType, but there is
>   also DependentSizedExtVectorType which handles dependent
>   attributes).
> 
> Given that align_value also needs to handle dependent alignment
> values, that seems most like the
> ExtVectorType/DependentSizedExtVectorType setup. I could create
> AlignValuePointerType/DependentAlignValuePointerType (or similar),
> maybe with AlignValuePointerType being a subclass of PointerType?
> (or maybe both being subclasses of PointerType?)
> 
> That having been said, creating subclasses of PointerType and/or new
> Type subclasses seems like an unfortunate amount of infrastructure
> for this feature. An alternative would be to place extra data
> directly into PointerType, but I don't like that idea because it
> adds memory (and some runtime) overhead to the common case with no
> corresponding benefit.
> 
> Ideally, I'd be able to use the original AlignValueAttr nodes,
> perhaps in combination with AttributedType somehow to indicate that
> a relevant AlignValueAttr node exists somewhere. Is there a way to
> do this?
> 
> In short, I'm not sure what the best way of doing this is, and I'm
> looking for advice.
> 
> Thanks again,
> Hal
> 
> > 
> > http://reviews.llvm.org/D4635
> > 
> > Files:
> >   include/clang/Basic/Attr.td
> >   include/clang/Basic/AttrDocs.td
> >   include/clang/Basic/DiagnosticSemaKinds.td
> >   include/clang/Sema/AttributeList.h
> >   include/clang/Sema/Sema.h
> >   lib/CodeGen/CGCall.cpp
> >   lib/Sema/SemaDeclAttr.cpp
> >   lib/Sema/SemaTemplateInstantiateDecl.cpp
> >   test/CodeGen/align_value.cpp
> >   test/Sema/align_value.c
> >   test/SemaCXX/align_value.cpp
> > 
> 
> --
> Hal Finkel
> Assistant Computational Scientist
> Leadership Computing Facility
> Argonne National Laboratory
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory



More information about the cfe-commits mailing list