[PATCH] align_value attribute in Clang

Hal Finkel hfinkel at anl.gov
Thu Sep 18 10:17:40 PDT 2014


----- Original Message -----
> From: "Alexey Bataev" <a.bataev at hotmail.com>
> To: "Hal Finkel" <hfinkel at anl.gov>
> Cc: "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, reviews+d4635+public+b7e82bdc1d8c324a at reviews.llvm.org
> Sent: Wednesday, September 17, 2014 9:01:45 PM
> Subject: Re: [PATCH] align_value attribute in Clang
> 
> Hi Hal,
> I'm not sure is it a proper solution, but I would try just to
> propagate
> this attribute on auto type deduction. Adding a new type will take a
> lot
> of time, though it is more perspective in terms of future extension
> for
> the new similar attributes.

In some sense, it seems like the right design is to do exactly this, because it is a light-weight solution and, aside from semantic checking and template-instantiation rewriting, we don't need to access the attribute until CodeGen. However, no other attribute is handled this way, and I'm not sure how feasible it is (would I need to modify code in only a few places?) and I don't know if this would be considered the right AST representation. Aaron, Richard, any thought on this?

Thanks again,
Hal

> 
> Best regards,
> Alexey Bataev
> =============
> Software Engineer
> Intel Compiler Team
> 
> 18.09.2014 3:25, Hal Finkel пишет:
> > ----- 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