LLVM  9.0.0svn
StackSafetyAnalysis.h
Go to the documentation of this file.
1 //===- StackSafetyAnalysis.h - Stack memory safety analysis -----*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Stack Safety Analysis detects allocas and arguments with safe access.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_ANALYSIS_STACKSAFETYANALYSIS_H
14 #define LLVM_ANALYSIS_STACKSAFETYANALYSIS_H
15 
16 #include "llvm/IR/PassManager.h"
17 #include "llvm/Pass.h"
18 
19 namespace llvm {
20 
21 /// Interface to access stack safety analysis results for single function.
23 public:
24  struct FunctionInfo;
25 
26 private:
27  std::unique_ptr<FunctionInfo> Info;
28 
29 public:
35 
36  // TODO: Add useful for client methods.
37  void print(raw_ostream &O) const;
38 };
39 
40 /// StackSafetyInfo wrapper for the new pass manager.
41 class StackSafetyAnalysis : public AnalysisInfoMixin<StackSafetyAnalysis> {
43  static AnalysisKey Key;
44 
45 public:
48 };
49 
50 /// Printer pass for the \c StackSafetyAnalysis results.
51 class StackSafetyPrinterPass : public PassInfoMixin<StackSafetyPrinterPass> {
52  raw_ostream &OS;
53 
54 public:
55  explicit StackSafetyPrinterPass(raw_ostream &OS) : OS(OS) {}
57 };
58 
59 /// StackSafetyInfo wrapper for the legacy pass manager
61  StackSafetyInfo SSI;
62 
63 public:
64  static char ID;
66 
67  const StackSafetyInfo &getResult() const { return SSI; }
68 
69  void print(raw_ostream &O, const Module *M) const override;
70  void getAnalysisUsage(AnalysisUsage &AU) const override;
71 
72  bool runOnFunction(Function &F) override;
73 };
74 
75 using StackSafetyGlobalInfo = std::map<const GlobalValue *, StackSafetyInfo>;
76 
77 /// This pass performs the global (interprocedural) stack safety analysis (new
78 /// pass manager).
80  : public AnalysisInfoMixin<StackSafetyGlobalAnalysis> {
82  static AnalysisKey Key;
83 
84 public:
86  Result run(Module &M, ModuleAnalysisManager &AM);
87 };
88 
89 /// Printer pass for the \c StackSafetyGlobalAnalysis results.
91  : public PassInfoMixin<StackSafetyGlobalPrinterPass> {
92  raw_ostream &OS;
93 
94 public:
95  explicit StackSafetyGlobalPrinterPass(raw_ostream &OS) : OS(OS) {}
97 };
98 
99 /// This pass performs the global (interprocedural) stack safety analysis
100 /// (legacy pass manager).
103 
104 public:
105  static char ID;
106 
108 
109  const StackSafetyGlobalInfo &getResult() const { return SSI; }
110 
111  void print(raw_ostream &O, const Module *M) const override;
112  void getAnalysisUsage(AnalysisUsage &AU) const override;
113 
114  bool runOnModule(Module &M) override;
115 };
116 
117 } // end namespace llvm
118 
119 #endif // LLVM_ANALYSIS_STACKSAFETYANALYSIS_H
This class represents lattice values for constants.
Definition: AllocatorList.h:23
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:372
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:20
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:153
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:389
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:284
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:224
StackSafetyPrinterPass(raw_ostream &OS)
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
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:70