Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
2.5 KiB

  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. #ifndef LLVM_ANALYSIS_CAPTURETRACKING_H
  14. #define LLVM_ANALYSIS_CAPTURETRACKING_H
  15. namespace llvm {
  16. class Value;
  17. class Use;
  18. /// PointerMayBeCaptured - Return true if this pointer value may be captured
  19. /// by the enclosing function (which is required to exist). This routine can
  20. /// be expensive, so consider caching the results. The boolean ReturnCaptures
  21. /// specifies whether returning the value (or part of it) from the function
  22. /// counts as capturing it or not. The boolean StoreCaptures specified
  23. /// whether storing the value (or part of it) into memory anywhere
  24. /// automatically counts as capturing it or not.
  25. bool PointerMayBeCaptured(const Value *V,
  26. bool ReturnCaptures,
  27. bool StoreCaptures);
  28. /// This callback is used in conjunction with PointerMayBeCaptured. In
  29. /// addition to the interface here, you'll need to provide your own getters
  30. /// to see whether anything was captured.
  31. struct CaptureTracker {
  32. virtual ~CaptureTracker();
  33. /// tooManyUses - The depth of traversal has breached a limit. There may be
  34. /// capturing instructions that will not be passed into captured().
  35. virtual void tooManyUses() = 0;
  36. /// shouldExplore - This is the use of a value derived from the pointer.
  37. /// To prune the search (ie., assume that none of its users could possibly
  38. /// capture) return false. To search it, return true.
  39. ///
  40. /// U->getUser() is always an Instruction.
  41. virtual bool shouldExplore(Use *U);
  42. /// captured - Information about the pointer was captured by the user of
  43. /// use U. Return true to stop the traversal or false to continue looking
  44. /// for more capturing instructions.
  45. virtual bool captured(Use *U) = 0;
  46. };
  47. /// PointerMayBeCaptured - Visit the value and the values derived from it and
  48. /// find values which appear to be capturing the pointer value. This feeds
  49. /// results into and is controlled by the CaptureTracker object.
  50. void PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker);
  51. } // end namespace llvm
  52. #endif