1 //===- llvm/Analysis/FindUnsafePointerTypes.h - Unsafe pointers -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines a pass that can be used to determine, interprocedurally,
11 // which pointer types are accessed unsafely in a program. If there is an
12 // "unsafe" access to a specific pointer type, transformations that depend on
13 // type safety cannot be permitted.
15 // The result of running this analysis over a program is a set of unsafe pointer
16 // types that cannot be transformed. Safe pointer types are not tracked.
18 // Additionally, this analysis exports a hidden command line argument that (when
19 // enabled) prints out the reasons a type was determined to be unsafe. Just add
20 // -printunsafeptrinst to the command line of the tool you want to get it.
22 //===----------------------------------------------------------------------===//
24 #ifndef LLVM_ANALYSIS_UNSAFEPOINTERTYPES_H
25 #define LLVM_ANALYSIS_UNSAFEPOINTERTYPES_H
27 #include "llvm/Pass.h"
34 struct FindUnsafePointerTypes : public Pass {
35 // UnsafeTypes - Set of types that are not safe to transform.
36 std::set<PointerType*> UnsafeTypes;
38 // Accessor for underlying type set...
39 inline const std::set<PointerType*> &getUnsafeTypes() const {
43 /// run - Inspect the operations that the specified module does on
44 /// values of various types. If they are deemed to be 'unsafe' note that the
45 /// type is not safe to transform.
47 virtual bool run(Module &M);
49 /// print - Loop over the results of the analysis, printing out unsafe types.
51 void print(std::ostream &o, const Module *Mod) const;
53 /// getAnalysisUsage - Of course, we provide ourself...
55 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
60 } // End llvm namespace