LLVM API Documentation
00001 //===----- llvm/Analysis/CaptureTracking.h - Pointer capture ----*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file contains routines that help determine which pointers are captured. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_ANALYSIS_CAPTURETRACKING_H 00015 #define LLVM_ANALYSIS_CAPTURETRACKING_H 00016 00017 namespace llvm { 00018 00019 class Value; 00020 class Use; 00021 00022 /// PointerMayBeCaptured - Return true if this pointer value may be captured 00023 /// by the enclosing function (which is required to exist). This routine can 00024 /// be expensive, so consider caching the results. The boolean ReturnCaptures 00025 /// specifies whether returning the value (or part of it) from the function 00026 /// counts as capturing it or not. The boolean StoreCaptures specified 00027 /// whether storing the value (or part of it) into memory anywhere 00028 /// automatically counts as capturing it or not. 00029 bool PointerMayBeCaptured(const Value *V, 00030 bool ReturnCaptures, 00031 bool StoreCaptures); 00032 00033 /// This callback is used in conjunction with PointerMayBeCaptured. In 00034 /// addition to the interface here, you'll need to provide your own getters 00035 /// to see whether anything was captured. 00036 struct CaptureTracker { 00037 virtual ~CaptureTracker(); 00038 00039 /// tooManyUses - The depth of traversal has breached a limit. There may be 00040 /// capturing instructions that will not be passed into captured(). 00041 virtual void tooManyUses() = 0; 00042 00043 /// shouldExplore - This is the use of a value derived from the pointer. 00044 /// To prune the search (ie., assume that none of its users could possibly 00045 /// capture) return false. To search it, return true. 00046 /// 00047 /// U->getUser() is always an Instruction. 00048 virtual bool shouldExplore(Use *U); 00049 00050 /// captured - Information about the pointer was captured by the user of 00051 /// use U. Return true to stop the traversal or false to continue looking 00052 /// for more capturing instructions. 00053 virtual bool captured(Use *U) = 0; 00054 }; 00055 00056 /// PointerMayBeCaptured - Visit the value and the values derived from it and 00057 /// find values which appear to be capturing the pointer value. This feeds 00058 /// results into and is controlled by the CaptureTracker object. 00059 void PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker); 00060 } // end namespace llvm 00061 00062 #endif