[llvm-commits] annotate known function declarations in SimplifyLibCalls pass

Duncan Sands baldrick at free.fr
Fri Jan 2 06:19:53 PST 2009


Hi Nick,

> +  for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
> +    Function &F = *I;
> +    const FunctionType *FTy = F.getFunctionType();

probably you only want to consider function declarations, not those
with bodies.

> +        if (NameLen == 6 && !strcmp(NameStr, "strlen")) {
> +          if (FTy->getNumParams() == 0 ||

Shouldn't this be "FTy->getNumParams() != 1"?

> +          if (!F.paramHasAttr(1, Attribute::NoCapture)) {

How about adding a "doesNotCapture" convenience method?

> +            F.addAttribute(1, Attribute::NoCapture);

How about adding setDoesNotCapture too.

> +          if (FTy->getNumParams() < 2 ||

Shouldn't this be != 2?  OK, I guess some take an extra argument.
But then shouldn't the type of the extra argument be checked?

Otherwise looks good, except for the lack of a testcase.

Ciao,

Duncan.



More information about the llvm-commits mailing list