Mahesh Attarde via llvm-dev
2015-Aug-12 09:49 UTC
[llvm-dev] Regarding Clang Custom Attributes, Visibility of Custom Attr in IR
Hi i wish to add Attribute on Function so i added def MutateFunction : InheritableAttr { let Spellings = [GNU<"mutate_function_hint">]; let Args = [UnsignedArgument<"SIndex">,UnsignedArgument<"RIndex">]; let Subjects = SubjectList<[Function], ErrorDiag>; let Documentation = [Undocumented]; } i have added function to hadle it, which simply adds attribute to Decl object When i dump this declaration in SemaDeclAttr.cpp: handleMutateFunction i get FunctionDecl 0xc9f9270 <kernel.cpp:6:12, line:7:1> col:1 k 'void (class Rad::Nav<short> &)' |-ParmVarDecl 0xc9f9000 <col:3, col:18> col:18 inParam 'class Rad::Nav<short>&' `-MutateFunction 0xc9f92e0 <line:6:40, col:68> 50 10 But this attribute is not visible in final IR. attribute #1 = { nounwind .... } How can i get it in #1? Thanks in advance> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150812/3a752f75/attachment.html>
Aaron Ballman via llvm-dev
2015-Aug-12 11:58 UTC
[llvm-dev] Regarding Clang Custom Attributes, Visibility of Custom Attr in IR
On Wed, Aug 12, 2015 at 5:49 AM, Mahesh Attarde via llvm-dev <llvm-dev at lists.llvm.org> wrote:> Hi > > i wish to add Attribute on Function so i added > > def MutateFunction : InheritableAttr { > let Spellings = [GNU<"mutate_function_hint">]; > let Args = [UnsignedArgument<"SIndex">,UnsignedArgument<"RIndex">]; > let Subjects = SubjectList<[Function], ErrorDiag>; > let Documentation = [Undocumented]; > } > > i have added function to hadle it, which simply adds attribute to Decl > object > > When i dump this declaration in SemaDeclAttr.cpp: handleMutateFunction i get > > FunctionDecl 0xc9f9270 <kernel.cpp:6:12, line:7:1> col:1 k 'void (class > Rad::Nav<short> &)' > |-ParmVarDecl 0xc9f9000 <col:3, col:18> col:18 inParam 'class > Rad::Nav<short>&' > `-MutateFunction 0xc9f92e0 <line:6:40, col:68> 50 10 > > But this attribute is not visible in final IR. > attribute #1 = { nounwind .... } > > How can i get it in #1? > Thanks in advance>Attributes in Clang do not translate automatically into attributes in LLVM; you have to modify the codegen to lower your attribute to an LLVM attribute. See CodeGenFunction.cpp for places where addFnAttr() are called as an example of one way to do this. HTH! ~Aaron> > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org http://llvm.cs.uiuc.edu > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >