Sort the #include lines for the include/... tree with the script.
[oota-llvm.git] / include / llvm / Analysis / CaptureTracking.h
1 //===----- llvm/Analysis/CaptureTracking.h - Pointer capture ----*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains routines that help determine which pointers are captured.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_ANALYSIS_CAPTURETRACKING_H
15 #define LLVM_ANALYSIS_CAPTURETRACKING_H
16
17 #include "llvm/Analysis/AliasAnalysis.h"
18 #include "llvm/Constants.h"
19 #include "llvm/Instructions.h"
20 #include "llvm/Support/CallSite.h"
21
22 namespace llvm {
23   /// PointerMayBeCaptured - Return true if this pointer value may be captured
24   /// by the enclosing function (which is required to exist).  This routine can
25   /// be expensive, so consider caching the results.  The boolean ReturnCaptures
26   /// specifies whether returning the value (or part of it) from the function
27   /// counts as capturing it or not.  The boolean StoreCaptures specified
28   /// whether storing the value (or part of it) into memory anywhere
29   /// automatically counts as capturing it or not.
30   bool PointerMayBeCaptured(const Value *V,
31                             bool ReturnCaptures,
32                             bool StoreCaptures);
33
34   /// This callback is used in conjunction with PointerMayBeCaptured. In
35   /// addition to the interface here, you'll need to provide your own getters
36   /// to see whether anything was captured.
37   struct CaptureTracker {
38     virtual ~CaptureTracker();
39
40     /// tooManyUses - The depth of traversal has breached a limit. There may be
41     /// capturing instructions that will not be passed into captured().
42     virtual void tooManyUses() = 0;
43
44     /// shouldExplore - This is the use of a value derived from the pointer.
45     /// To prune the search (ie., assume that none of its users could possibly
46     /// capture) return false. To search it, return true.
47     ///
48     /// U->getUser() is always an Instruction.
49     virtual bool shouldExplore(Use *U);
50
51     /// captured - Information about the pointer was captured by the user of
52     /// use U. Return true to stop the traversal or false to continue looking
53     /// for more capturing instructions.
54     virtual bool captured(Use *U) = 0;
55   };
56
57   /// PointerMayBeCaptured - Visit the value and the values derived from it and
58   /// find values which appear to be capturing the pointer value. This feeds
59   /// results into and is controlled by the CaptureTracker object.
60   void PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker);
61 } // end namespace llvm
62
63 #endif