<div dir="ltr">Hello Clang Developers,<div><br></div><div>I want to add a new attribute which is required to work with function declaration as shown in example given below:</div><div><br></div><div><div>extern void foo(int param) __attribute__((regmask("R8,R11")));</div><div><br></div><div>int foo2(int param) {</div><div><span class="" style="white-space:pre">    </span>foo(param);</div><div><span class="" style="white-space:pre">        </span>return param;</div><div>}</div></div><div><br></div><div>For this I have done following changes:</div><div><br></div><div>Attr.td</div><div><br></div><div>def RegMask : Attr {</div><div>  let Spellings = [GNU<"regmask">];</div><div>  let Args = [StringArgument<"ClobbersList">];</div><div>  let Subjects = SubjectList<[Function]>;</div><div>  let Documentation = [Undocumented];</div><div>} </div><div><br></div><div>lib/Sema/SemaDeclAttr.cpp</div><div><br></div><div><div>static void handleRegMaskAttr(Sema &S, Decl *D, const AttributeList &Attr) {</div><div>  // Make sure that there is a string literal as the annotation's single</div><div>  // argument.</div><div>  StringRef Str;</div><div>  if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str))</div><div>    return;</div><div><br></div><div>  D->addAttr(::new (S.Context)</div><div>             AnnotateAttr(Attr.getRange(), S.Context, Str,</div><div>                          Attr.getAttributeSpellingListIndex()));</div><div>  llvm::dbgs() << "Reg Mask attribute : " << Str << "\n";</div><div>}</div></div><div><br></div><div>above method is very similar to handleAnnotateAttr</div><div><br></div><div>and use this method inside ProcessDeclAttribute method as follows :</div><div><br></div><div>// Attribute to help interprocedural register allocation</div><div>  case AttributeList::AT_RegMask:</div><div>    handleRegMaskAttr(S, D, Attr);</div><div>    break;</div><div>  }</div><div><br></div><div>but this does not work for me, it works on function definitions but not with function declaration.</div><div><br></div><div>Am I missing here any thing?</div><div><br></div><div>Note: I want to parse this string at MI level if possible or at IR level to create a RegMask out of that.</div><div><br></div><div>Sincerely,</div><div>Vivek </div></div>