[llvm-commits] [128471] Add annotate attribute.
Duncan Sands
baldrick at free.fr
Sat Jun 16 00:50:15 PDT 2007
Hi,
> + // Add llvm.global.annotations
> + if (!AttributeAnnotateGlobals.empty()) {
> + std::vector<Constant*> AttrList;
since you know how big this vector is going to be, you could reserve that much
space here.
> + for (unsigned i = 0, e = AttributeAnnotateGlobals.size(); i != e; ++i) {
> + Constant *Elts[2] = {AttributeAnnotateGlobals[i].first,
> + AttributeAnnotateGlobals[i].second };
> + AttrList.push_back(ConstantStruct::get(Elts, 2, false));
> + }
You presumably could have done this at the point where values are added to
AttributeAnnotateGlobals, eliminating the need for AttrList altogether.
> + gv->setSection("llvm.metadata");
At this point you can presumably empty out AttributeAnnotateGlobals, freeing
memory.
> + if (!annotateAttr)
> + return;
No need for this return statement, since if annotateAttr is NULL then
> + // There may be multiple annotate attributes. Pass return of lookup_attr
> + // to successive lookups.
> + while (annotateAttr) {
this while loop is never executed.
Ciao,
Duncan.
More information about the llvm-commits
mailing list