aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Analysis/FindUnsafePointerTypes.h
blob: cd34676727e89927a366e54d75020dd8ae8eead8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//===- llvm/Analysis/SafePointerAccess.h - Check pointer safety ---*- C++ -*-=//
//
// This file defines a pass that can be used to determine, interprocedurally, 
// which pointer types are accessed unsafely in a program.  If there is an
// "unsafe" access to a specific pointer type, transformations that depend on
// type safety cannot be permitted.
//
// The result of running this analysis over a program is a set of unsafe pointer
// types that cannot be transformed.  Safe pointer types are not tracked.
//
// Additionally, this analysis exports a hidden command line argument that (when
// enabled) prints out the reasons a type was determined to be unsafe.  Just add
// -unsafeptrinst to the command line of the tool you want to get it.
// 
//===----------------------------------------------------------------------===//

#ifndef LLVM_ANALYSIS_SAFEPOINTERACCESS_H
#define LLVM_ANALYSIS_SAFEPOINTERACCESS_H

#include "llvm/Pass.h"
#include <set>

class PointerType;

struct FindUnsafePointerTypes : public Pass {
  // UnsafeTypes - Set of types that are not safe to transform.
  std::set<PointerType*> UnsafeTypes;
public:
  static AnalysisID ID;    // We are an analysis, we must have an ID

  FindUnsafePointerTypes(AnalysisID id) { assert(ID == id); }

  // Accessor for underlying type set...
  inline const std::set<PointerType*> &getUnsafeTypes() const {
    return UnsafeTypes;
  }

  // run - Inspect the operations that the specified module does on
  // values of various types.  If they are deemed to be 'unsafe' note that the
  // type is not safe to transform.
  //
  virtual bool run(Module *M);

  // printResults - Loop over the results of the analysis, printing out unsafe
  // types.
  //
  void printResults(const Module *Mod, std::ostream &o) const;

  // getAnalysisUsageInfo - This function needs FindUsedTypes to do its job...
  //
  virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Required,
                                    Pass::AnalysisSet &Destroyed,
                                    Pass::AnalysisSet &Provided);
};

#endif