LLVM  8.0.1
StackSafetyAnalysis.h
Go to the documentation of this file.
1 //===- StackSafetyAnalysis.h - Stack memory safety analysis -----*- 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 // Stack Safety Analysis detects allocas and arguments with safe access.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_ANALYSIS_STACKSAFETYANALYSIS_H
15 #define LLVM_ANALYSIS_STACKSAFETYANALYSIS_H
16 
17 #include "llvm/IR/PassManager.h"
18 #include "llvm/Pass.h"
19 
20 namespace llvm {
21 
22 /// Interface to access stack safety analysis results for single function.
24 public:
25  struct FunctionInfo;
26 
27 private:
28  std::unique_ptr<FunctionInfo> Info;
29 
30 public:
36 
37  // TODO: Add useful for client methods.
38  void print(raw_ostream &O) const;
39 };
40 
41 /// StackSafetyInfo wrapper for the new pass manager.
42 class StackSafetyAnalysis : public AnalysisInfoMixin<StackSafetyAnalysis> {
44  static AnalysisKey Key;
45 
46 public:
49 };
50 
51 /// Printer pass for the \c StackSafetyAnalysis results.
52 class StackSafetyPrinterPass : public PassInfoMixin<StackSafetyPrinterPass> {
53  raw_ostream &OS;
54 
55 public:
56  explicit StackSafetyPrinterPass(raw_ostream &OS) : OS(OS) {}
58 };
59 
60 /// StackSafetyInfo wrapper for the legacy pass manager
62  StackSafetyInfo SSI;
63 
64 public:
65  static char ID;
67 
68  const StackSafetyInfo &getResult() const { return SSI; }
69 
70  void print(raw_ostream &O, const Module *M) const override;
71  void getAnalysisUsage(AnalysisUsage &AU) const override;
72 
73  bool runOnFunction(Function &F) override;
74 };
75 
76 using StackSafetyGlobalInfo = std::map<const GlobalValue *, StackSafetyInfo>;
77 
78 /// This pass performs the global (interprocedural) stack safety analysis (new
79 /// pass manager).
81  : public AnalysisInfoMixin<StackSafetyGlobalAnalysis> {
83  static AnalysisKey Key;
84 
85 public:
87  Result run(Module &M, ModuleAnalysisManager &AM);
88 };
89 
90 /// Printer pass for the \c StackSafetyGlobalAnalysis results.
92  : public PassInfoMixin<StackSafetyGlobalPrinterPass> {
93  raw_ostream &OS;
94 
95 public:
96  explicit StackSafetyGlobalPrinterPass(raw_ostream &OS) : OS(OS) {}
98 };
99 
100 /// This pass performs the global (interprocedural) stack safety analysis
101 /// (legacy pass manager).
104 
105 public:
106  static char ID;
107 
109 
110  const StackSafetyGlobalInfo &getResult() const { return SSI; }
111 
112  void print(raw_ostream &O, const Module *M) const override;
113  void getAnalysisUsage(AnalysisUsage &AU) const override;
114 
115  bool runOnModule(Module &M) override;
116 };
117 
118 } // end namespace llvm
119 
120 #endif // LLVM_ANALYSIS_STACKSAFETYANALYSIS_H
This class represents lattice values for constants.
Definition: AllocatorList.h:24
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
F(f)
StackSafetyInfo & operator=(StackSafetyInfo &&)
Key
PAL metadata keys.
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:366
Describes uses of allocas and parameters inside of a single function.
This pass performs the global (interprocedural) stack safety analysis (legacy pass manager)...
Analysis containing CSE Info
Definition: CSEInfo.cpp:21
const StackSafetyGlobalInfo & getResult() const
StackSafetyInfo wrapper for the new pass manager.
static bool runOnFunction(Function &F, bool PostInlining)
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:154
Interface to access stack safety analysis results for single function.
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:383
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:285
This pass performs the global (interprocedural) stack safety analysis (new pass manager).
StackSafetyInfo wrapper for the legacy pass manager.
void print(raw_ostream &O) const
Printer pass for the StackSafetyAnalysis results.
std::map< const GlobalValue *, StackSafetyInfo > StackSafetyGlobalInfo
const StackSafetyInfo & getResult() const
Printer pass for the StackSafetyGlobalAnalysis results.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition: Pass.h:225
StackSafetyPrinterPass(raw_ostream &OS)
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
A container for analyses that lazily runs them and caches their results.
This header defines various interfaces for pass management in LLVM.
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:71