From 6e5fd6e8508eaf861c28d980ea94c648dd1abab9 Mon Sep 17 00:00:00 2001 From: Pankaj Gode Date: Fri, 22 Nov 2019 18:40:47 +0530 Subject: [PATCH] [WIP][Attributor] AAReachability Attribute Summary: Working towards Johannes's suggestion for fixme, in Attributor's Noalias attribute deduction. (ii) Check whether the value is captured in the scope using AANoCapture. FIXME: This is conservative though, it is better to look at CFG and // check only uses possibly executed before this call site. A Reachability abstract attribute answers the question "does execution at point A potentially reach point B". If this question is answered with false for all other uses of the value that might be captured, we know it is not *yet* captured and can continue with the noalias deduction. Currently, information AAReachability provides is completely pessimistic. Reviewers: jdoerfert Reviewed By: jdoerfert Subscribers: uenoku, sstefan1, hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D70233 --- include/llvm/Transforms/IPO/Attributor.h | 31 ++++++++++++++++++++++++ lib/Transforms/IPO/Attributor.cpp | 30 +++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/include/llvm/Transforms/IPO/Attributor.h b/include/llvm/Transforms/IPO/Attributor.h index 70a95ad33c9..a75a047b7fd 100644 --- a/include/llvm/Transforms/IPO/Attributor.h +++ b/include/llvm/Transforms/IPO/Attributor.h @@ -1682,6 +1682,37 @@ struct AAWillReturn static const char ID; }; +/// An abstract interface to determine reachability of point A to B. +struct AAReachability : public StateWrapper, + public IRPosition { + AAReachability(const IRPosition &IRP) : IRPosition(IRP) {} + + /// Returns true if 'From' instruction is assumed to reach, 'To' instruction. + /// Users should provide two positions they are interested in, and the class + /// determines (and caches) reachability. + bool isAssumedReachable(const Instruction *From, + const Instruction *To) const { + return true; + } + + /// Returns true if 'From' instruction is known to reach, 'To' instruction. + /// Users should provide two positions they are interested in, and the class + /// determines (and caches) reachability. + bool isKnownReachable(const Instruction *From, const Instruction *To) const { + return true; + } + + /// Return an IR position, see struct IRPosition. + const IRPosition &getIRPosition() const override { return *this; } + + /// Create an abstract attribute view for the position \p IRP. + static AAReachability &createForPosition(const IRPosition &IRP, + Attributor &A); + + /// Unique ID (due to the unique address) + static const char ID; +}; + /// An abstract interface for all noalias attributes. struct AANoAlias : public IRAttribute