Static Value-Flow Analysis
Loading...
Searching...
No Matches
BreakConstantExpr.h
Go to the documentation of this file.
1//===- BreakConstantGEPs.h - Change constant GEPs into GEP instructions --- --//
2//
3// The SAFECode Compiler
4//
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.
7//
8//===----------------------------------------------------------------------===//
9//
10// This pass changes all GEP constant expressions into GEP instructions. This
11// permits the rest of SAFECode to put run-time checks on them if necessary.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef BREAKCONSTANTGEPS_H
16#define BREAKCONSTANTGEPS_H
17
18#include "llvm/Passes/PassBuilder.h"
19#include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h"
20
21namespace SVF
22{
23
24//
25// Pass: BreakConstantGEPs
26//
27// Description:
28// This pass modifies a function so that it uses GEP instructions instead of
29// GEP constant expressions.
30//
32{
33private:
34 // Private methods
35
36 // Private variables
37
38public:
39 static char ID;
41 llvm::StringRef getPassName() const
42 {
43 return "Remove Constant GEP Expressions";
44 }
45 virtual bool runOnModule (Module & M);
46};
47
48
49//
50// Pass: MergeFunctionRets
51//
52// Description:
53// This pass modifies a function so that each function only have one unified exit basic block
54//
56{
57private:
58 // Private methods
59
60 // Private variables
61
62public:
63 static char ID;
65 llvm::StringRef getPassName() const
66 {
67 return "unify function exit into one dummy exit basic block";
68 }
69 virtual bool runOnModule (Module & M)
70 {
72 return true;
73 }
74 inline void UnifyFunctionExit(Module& module)
75 {
76 for (Module::const_iterator iter = module.begin(), eiter = module.end();
77 iter != eiter; ++iter)
78 {
79 const Function& fun = *iter;
80 if(fun.isDeclaration())
81 continue;
82 llvm::PassBuilder PB;
83 llvm::LoopAnalysisManager LAM;
84 llvm::FunctionAnalysisManager FAM;
85 llvm::CGSCCAnalysisManager CGAM;
86 llvm::ModuleAnalysisManager MAM;
87
88 PB.registerModuleAnalyses(MAM);
89 PB.registerCGSCCAnalyses(CGAM);
90 PB.registerFunctionAnalyses(FAM);
91 PB.registerLoopAnalyses(LAM);
92 PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
93
94 llvm::FunctionPassManager FPM;
95 FPM.addPass(llvm::UnifyFunctionExitNodesPass());
96 FPM.run(const_cast<llvm::Function&>(fun), FAM);
97 }
98 }
99};
100
101} // End namespace SVF
102
103#endif
llvm::StringRef getPassName() const
virtual bool runOnModule(Module &M)
llvm::StringRef getPassName() const
void UnifyFunctionExit(Module &module)
virtual bool runOnModule(Module &M)
for isBitcode
Definition BasicTypes.h:70
llvm::Function Function
Definition BasicTypes.h:83
llvm::Module Module
Definition BasicTypes.h:82
llvm::ModulePass ModulePass
Definition BasicTypes.h:75