[PATCH] D15676: [attrs] Extract the pure inference of function attributes into a standalone pass.

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 20 02:53:21 PST 2015


chandlerc created this revision.
chandlerc added reviewers: jmolloy, joker.eph.
chandlerc added a subscriber: llvm-commits.
chandlerc added a dependency: D15668: [attrs] Split off the forced attributes utility into its own pass that can be potentially run much earlier than FuncitonAttrs proper..
Herald added a subscriber: joker.eph.

There is no call graph or even interesting analysis for this part of
function attributes -- it is literally inferring attributes based on the
target library identification. As such, we can do it using a much
simpler module pass that just walks the declarations. This can also
happen much earlier in the pass pipeline which has benefits for any
number of other passes.

In the process, I've had to clean up several aspects of this logic.
First, the pass now counts inferred attributes independently rather than
just counting all the inferred attributes as one, and the counts are
more clearly explained. Second, the pass infers at least some of the
library functions as norecurse. I've been *exceedingly* conservative
here and only added it for library functions that I could instantly and
confidently make this claim. Things like printf and malloc or any
function which I could imagine some how, even through very strange steps
such as malloc hooks or a recursive printf implementation, I left alone.
This at least allowed me to keep the no-recurse logic in place rather
than having to delete it for being unused just to add it back when we
decide to finish annotating such things. We should go through and be
more aggressive about norecurse I suspect.

The two test cases we had for this code path are both ... woefully
inadequate and copies of each other. I've kept the superset test and
updated it. We need more testing here, but I had to pick somewhere to
stop fixing everything broken I saw here.

Depends on D15668.

http://reviews.llvm.org/D15676

Files:
  include/llvm/InitializePasses.h
  include/llvm/Transforms/IPO/InferFunctionAttrs.h
  lib/Passes/PassBuilder.cpp
  lib/Transforms/IPO/CMakeLists.txt
  lib/Transforms/IPO/FunctionAttrs.cpp
  lib/Transforms/IPO/IPO.cpp
  lib/Transforms/IPO/InferFunctionAttrs.cpp
  lib/Transforms/IPO/PassManagerBuilder.cpp
  test/Transforms/FunctionAttrs/2009-01-04-Annotate.ll
  test/Transforms/FunctionAttrs/annotate-1.ll
  test/Transforms/InferFunctionAttrs/annotate.ll
  test/Transforms/InstCombine/strto-1.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15676.43322.patch
Type: text/x-patch
Size: 70731 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151220/bf90f7f8/attachment.bin>


More information about the llvm-commits mailing list