[llvm-commits] annotate known function declarations in SimplifyLibCalls pass
Chris Lattner
clattner at apple.com
Fri Jan 2 12:42:05 PST 2009
On Jan 1, 2009, at 5:49 PM, Nick Lewycky wrote:
> This patch modifies SimplifyLibCalls to run a post-pass that adds
> attributes to many well-known functions. I'm sending this out for
> review because there's a lot of decisions I made that should be
> checked before the commit:
In addition to Duncan's comments, please add a helper method for this
pattern:
> + if (!F.doesNotThrow()) {
> + F.setDoesNotThrow();
> + ++NumAnnotated;
> + Modified = true;
> + }
> + if (!F.paramHasAttr(1, Attribute::NoCapture)) {
> + F.addAttribute(1, Attribute::NoCapture);
> + ++NumAnnotated;
> + Modified = true;
> + }
> + if (!F.paramHasAttr(2, Attribute::NoCapture)) {
> + F.addAttribute(2, Attribute::NoCapture);
> + ++NumAnnotated;
> + Modified = true;
> + }
It would be much better to just call:
SetFunctionAttribute(F, Attribute::DoesNotThrow);
SetParamAttribute(F, 0, Attribute::NoCapture);
SetParamAttribute(F, 1, Attribute::NoCapture);
And have the "set*attribute" helper method handle the checking to see
if the attribute already exists, the bumping of numannotated and
setting of Modified.
-Chris
More information about the llvm-commits
mailing list