Skip to content

Commit

Permalink
[Attributor] Deduce the "returned" argument attribute
Browse files Browse the repository at this point in the history
Deduce the "returned" argument attribute by collecting all potentially
returned values.

Not only the unique return value, if any, can be used by subsequent
attributes but also the set of all potentially returned values as well
as the mapping from returned values to return instructions that they
originate from (see AAReturnedValues::checkForallReturnedValues).

Change in statistics (-stats) for LLVM-TS + Spec2006, totaling ~19% more "returned" arguments.

  ADDED: attributor                   NumAttributesManifested                  n/a ->        637
  ADDED: attributor                   NumAttributesValidFixpoint               n/a ->      25545
  ADDED: attributor                   NumFnArgumentReturned                    n/a ->        637
  ADDED: attributor                   NumFnKnownReturns                        n/a ->      25545
  ADDED: attributor                   NumFnUniqueReturned                      n/a ->      14118
CHANGED: deadargelim                  NumRetValsEliminated                     470 ->        449 (    -4.468%)
REMOVED: functionattrs                NumReturned                              535 ->        n/a
CHANGED: indvars                      NumElimIdentity                          138 ->        164 (   +18.841%)

Reviewers: homerdin, hfinkel, fedor.sergeev, sanjoy, spatel, nlopes, nicholas, reames, efriedma, chandlerc

Subscribers: hiraditya, bollu, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

llvm-svn: 365407
  • Loading branch information
Johannes Doerfert committed Jul 8, 2019
1 parent 793231c commit accd3e8
Show file tree
Hide file tree
Showing 5 changed files with 687 additions and 89 deletions.
21 changes: 21 additions & 0 deletions llvm/include/llvm/Transforms/IPO/Attributor.h
Expand Up @@ -642,6 +642,27 @@ Pass *createAttributorLegacyPass();
/// Abstract Attribute Classes
/// ----------------------------------------------------------------------------

/// An abstract attribute for the returned values of a function.
struct AAReturnedValues : public AbstractAttribute {
/// See AbstractAttribute::AbstractAttribute(...).
AAReturnedValues(Function &F, InformationCache &InfoCache)
: AbstractAttribute(F, InfoCache) {}

/// Check \p Pred on all returned values.
///
/// This method will evaluate \p Pred on returned values and return
/// true if (1) all returned values are known, and (2) \p Pred returned true
/// for all returned values.
virtual bool
checkForallReturnedValues(std::function<bool(Value &)> &Pred) const = 0;

/// See AbstractAttribute::getAttrKind()
virtual Attribute::AttrKind getAttrKind() const override { return ID; }

/// The identifier used by the Attributor for this class of attributes.
static constexpr Attribute::AttrKind ID = Attribute::Returned;
};

struct AANoUnwind : public AbstractAttribute {
/// An abstract interface for all nosync attributes.
AANoUnwind(Value &V, InformationCache &InfoCache)
Expand Down

0 comments on commit accd3e8

Please sign in to comment.