-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCFLAndersTaintAnalysis.h
More file actions
96 lines (74 loc) · 2.9 KB
/
CFLAndersTaintAnalysis.h
File metadata and controls
96 lines (74 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//==- CFLAndersAliasAnalysis.h - Unification-based Alias Analysis -*- C++-*-==//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/// \file
/// This is the interface for LLVM's inclusion-based alias analysis
/// implemented with CFL graph reachability.
///
//===----------------------------------------------------------------------===//
#ifndef LLVM_ANALYSIS_CFLANDERSTAINTANALYSIS_H
#define LLVM_ANALYSIS_CFLANDERSTAINTANALYSIS_H
#include "AliasAnalysisSummary.h"
#include "CFLTaintAnalysisUtils.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/Optional.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Pass.h"
#include <forward_list>
#include <memory>
namespace llvm {
class Function;
class MemoryLocation;
class TargetLibraryInfo;
class CFLAndersTaintResult : public AAResultBase<CFLAndersTaintResult> {
friend AAResultBase<CFLAndersTaintResult>;
class FunctionInfo;
public:
explicit CFLAndersTaintResult(const TargetLibraryInfo &TLI);
CFLAndersTaintResult(CFLAndersTaintResult &&RHS);
~CFLAndersTaintResult();
Optional<DenseSet<Value *>> taintedVals(const Function &Fn);
DenseMap<const Function *, DenseSet<Value *>> taintedValsInReachableFuncs(const Function &Fn);
void buildInfoFrom(const Module &);
private:
const TargetLibraryInfo &TLI;
/// Cached mapping of Functions to their StratifiedSets.
/// If a function's sets are currently being built, it is marked
/// in the cache as an Optional without a value. This way, if we
/// have any kind of recursion, it is discernable from a function
/// that simply has empty sets.
DenseMap<const Function *, DenseSet<Value *>> TaintedValMap;
};
/// Analysis pass providing a never-invalidated alias analysis result.
///
/// FIXME: We really should refactor CFL to use the analysis more heavily, and
/// in particular to leverage invalidation to trigger re-computation.
class CFLAndersAA : public AnalysisInfoMixin<CFLAndersAA> {
friend AnalysisInfoMixin<CFLAndersAA>;
static AnalysisKey Key;
public:
using Result = CFLAndersTaintResult;
CFLAndersTaintResult run(Function &F, FunctionAnalysisManager &AM);
};
/// Legacy wrapper pass to provide the CFLAndersTaintResult object.
class CFLAndersTaintWrapperPass : public ModulePass {
std::unique_ptr<CFLAndersTaintResult> Result;
public:
static char ID;
CFLAndersTaintWrapperPass();
CFLAndersTaintResult &getResult() { return *Result; }
const CFLAndersTaintResult &getResult() const { return *Result; }
bool runOnModule(Module &M);
//void initializePass() override;
void getAnalysisUsage(AnalysisUsage &AU) const override;
};
ModulePass *createCFLAndersTaintWrapperPass();
} // end namespace llvm
#endif