[PATCH] D14497: [FunctionAttrs] Detect printf-like functions and propagate readonly+nocapture to variadic operands

James Molloy via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 16 07:28:03 PST 2015


jmolloy retitled this revision from "[FunctionAttrs] Detect printf-like functions and propagate readnone+nocapture to variadic operands" to "[FunctionAttrs] Detect printf-like functions and propagate readonly+nocapture to variadic operands".
jmolloy updated the summary for this revision.
jmolloy updated this revision to Diff 40285.
jmolloy added a comment.

Hi David, Eli,

Thanks for looking this over. Eli, thanks for jumping in - you're completely right, and I hadn't considered this.

Going back to the drawing board a little, I think the single most important thing to be able to handle is "%s" specifiers. These are obviously incredibly common and I'd argue are might contribute the most to (non-legitmately) escaping pointers.

The revamped patch adds parsing support for printf-style format strings. The parsing isn't perfect, but it doesn't need to be - a best-effort approach is probably good enough for most cases.

The new patch will only ever add readonly+nocapture to pointer arguments known to be used in %s specifiers. It can be extended if we later find we want to infer attributes on other arguments (perhaps %p/%d/%u can still be readonly, just not nocapture? and %n can be nocapture but not readonly?)

I appreciate it's now significantly more code.

Cheers,

James


Repository:
  rL LLVM

http://reviews.llvm.org/D14497

Files:
  lib/Transforms/IPO/FunctionAttrs.cpp
  test/Transforms/FunctionAttrs/varargs.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14497.40285.patch
Type: text/x-patch
Size: 14430 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151116/349cf0ff/attachment.bin>


More information about the llvm-commits mailing list