[PM][FunctionAttrs] add NoUnwind attribute inference to PostOrderFunctionAttrs pass
authorFedor Sergeev <fedor.sergeev@azul.com>
Fri, 23 Mar 2018 21:46:16 +0000 (21:46 +0000)
committerFedor Sergeev <fedor.sergeev@azul.com>
Fri, 23 Mar 2018 21:46:16 +0000 (21:46 +0000)
commit6660fd0f959e2e07db47729fb6112b7a823a67c2
tree169742b681fa951ba09dbd061f387cb6d8f7c10e
parentb53180846b7cd2489b1f99271010214de0dc4533
[PM][FunctionAttrs] add NoUnwind attribute inference to PostOrderFunctionAttrs pass

Summary:
This was motivated by absence of PrunEH functionality in new PM.
It was decided that a proper way to do PruneEH is to add NoUnwind inference
into PostOrderFunctionAttrs and then perform normal SimplifyCFG on top.

This change generalizes attribute handling implemented for (a removal of)
Convergent attribute, by introducing a generic builder-like class
   AttributeInferer

It registers all the attribute inference requests, storing per-attribute
predicates into a vector, and then goes through an SCC Node, scanning all
the instructions for not breaking attribute assumptions.

The main idea is that as soon all the instructions from all the functions
of SCC Node conform to attribute assumptions then we are free to infer
the attribute as set for all the functions of SCC Node.

It handles two distinct cases of attributes:
   - those that might break due to derefinement of the function code

     for these attributes we are allowed to apply inference only if all the
     functions are "exact definitions". Example - NoUnwind.

   - those that do not care about derefinement

     for these attributes we are allowed to apply inference as soon as we see
     any function definition. Example - removal of Convergent attribute.

Also in this commit:
* Converted all the FunctionAttrs tests to use FileCheck and added new-PM
  invocations to them

* FunctionAttrs/convergent.ll test demonstrates a difference in behavior between
   new and old PM implementations. Marked with FIXME.

* PruneEH tests were converted to new-PM as well, using function-attrs+simplify-cfg
  combo as intended

* some of "other" tests were updated since function-attrs now infers 'nounwind'
  even for old PM pipeline

* -disable-nounwind-inference hidden option added as a possible workaround for a supposedly
  rare case when nounwind being inferred by default presents a problem

Reviewers: chandlerc, jlebar

Reviewed By: jlebar

Subscribers: eraman, llvm-commits

Differential Revision: https://reviews.llvm.org/D44415

llvm-svn: 328377
32 files changed:
llvm/lib/Transforms/IPO/FunctionAttrs.cpp
llvm/test/Other/cgscc-devirt-iteration.ll
llvm/test/Transforms/FunctionAttrs/2008-09-03-Mutual.ll
llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadNone.ll
llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadOnly.ll
llvm/test/Transforms/FunctionAttrs/2008-09-13-VolatileRead.ll
llvm/test/Transforms/FunctionAttrs/2008-12-29-Constant.ll
llvm/test/Transforms/FunctionAttrs/2009-01-02-LocalStores.ll
llvm/test/Transforms/FunctionAttrs/2010-10-30-volatile.ll
llvm/test/Transforms/FunctionAttrs/assume.ll
llvm/test/Transforms/FunctionAttrs/atomic.ll
llvm/test/Transforms/FunctionAttrs/comdat-ipo.ll
llvm/test/Transforms/FunctionAttrs/convergent.ll
llvm/test/Transforms/FunctionAttrs/int_sideeffect.ll
llvm/test/Transforms/FunctionAttrs/nocapture.ll
llvm/test/Transforms/FunctionAttrs/nonnull-global.ll
llvm/test/Transforms/FunctionAttrs/nonnull.ll
llvm/test/Transforms/FunctionAttrs/norecurse.ll
llvm/test/Transforms/FunctionAttrs/operand-bundles-scc.ll
llvm/test/Transforms/FunctionAttrs/optnone.ll
llvm/test/Transforms/FunctionAttrs/out-of-bounds-iterator-bug.ll
llvm/test/Transforms/FunctionAttrs/readnone.ll
llvm/test/Transforms/FunctionAttrs/returned.ll
llvm/test/Transforms/Inline/cgscc-update.ll
llvm/test/Transforms/PruneEH/2008-06-02-Weak.ll
llvm/test/Transforms/PruneEH/ipo-nounwind.ll
llvm/test/Transforms/PruneEH/operand-bundles.ll
llvm/test/Transforms/PruneEH/pr23971.ll
llvm/test/Transforms/PruneEH/pr26263.ll
llvm/test/Transforms/PruneEH/recursivetest.ll
llvm/test/Transforms/PruneEH/seh-nounwind.ll
llvm/test/Transforms/PruneEH/simpletest.ll