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#if LLVM_VERSION_MAJOR > 16
19#include "llvm/Passes/PassBuilder.h"
20#include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h"
21#endif
22
23namespace SVF
24{
25
26//
27// Pass: BreakConstantGEPs
28//
29// Description:
30// This pass modifies a function so that it uses GEP instructions instead of
31// GEP constant expressions.
32//
34{
35private:
36 // Private methods
37
38 // Private variables
39
40public:
41 static char ID;
43 llvm::StringRef getPassName() const
44 {
45 return "Remove Constant GEP Expressions";
46 }
47 virtual bool runOnModule (Module & M);
48};
49
50
51//
52// Pass: MergeFunctionRets
53//
54// Description:
55// This pass modifies a function so that each function only have one unified exit basic block
56//
58{
59private:
60 // Private methods
61
62 // Private variables
63
64public:
65 static char ID;
67 llvm::StringRef getPassName() const
68 {
69 return "unify function exit into one dummy exit basic block";
70 }
71 virtual bool runOnModule (Module & M)
72 {
74 return true;
75 }
77 {
78 for (Module::const_iterator iter = module.begin(), eiter = module.end();
79 iter != eiter; ++iter)
80 {
81 const Function& fun = *iter;
82 if(fun.isDeclaration())
83 continue;
84#if LLVM_VERSION_MAJOR > 16
85 llvm::PassBuilder PB;
86 llvm::LoopAnalysisManager LAM;
87 llvm::FunctionAnalysisManager FAM;
88 llvm::CGSCCAnalysisManager CGAM;
89 llvm::ModuleAnalysisManager MAM;
90
91 PB.registerModuleAnalyses(MAM);
92 PB.registerCGSCCAnalyses(CGAM);
93 PB.registerFunctionAnalyses(FAM);
94 PB.registerLoopAnalyses(LAM);
95 PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
96
97 llvm::FunctionPassManager FPM;
98 FPM.addPass(llvm::UnifyFunctionExitNodesPass());
99 FPM.run(const_cast<llvm::Function&>(fun), FAM);
100 }
101 }
102#else
103 getUnifyExit(fun)->runOnFunction(const_cast<Function&>(fun));
104 }
105 }
108 {
109 assert(!fn.isDeclaration() && "external function does not have DF");
110 return &getAnalysis<UnifyFunctionExitNodes>(const_cast<Function&>(fn));
111 }
112#endif
113};
114
115} // End namespace SVF
116
117#endif
llvm::StringRef getPassName() const
virtual bool runOnModule(Module &M)
UnifyFunctionExitNodes * getUnifyExit(const Function &fn)
Get Unified Exit basic block node.
llvm::StringRef getPassName() const
void UnifyFunctionExit(Module &module)
virtual bool runOnModule(Module &M)
for isBitcode
Definition BasicTypes.h:68
llvm::Function Function
Definition BasicTypes.h:87
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74
llvm::Module Module
Definition BasicTypes.h:86
llvm::ModulePass ModulePass
Definition BasicTypes.h:73
llvm::UnifyFunctionExitNodes UnifyFunctionExitNodes
Definition BasicTypes.h:80