CPAnalysis.cpp
1.51 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
//===- CPAnalysis.cpp
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the constant propagation analysis.
//
//===----------------------------------------------------------------------===//
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Instruction.h"
#include "llvm/Pass.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/InstIterator.h"
using namespace llvm;
namespace {
struct CPAnalysis : public ModulePass {
static char ID;
CPAnalysis() : ModulePass(ID) {}
virtual bool runOnModule(Module &M) {
unsigned opcode;
IRBuilder<> builder(M.getContext());
// Iterating over all the functions in the module
for (Module::iterator FB = M.begin(), FE = M.end(); FB != FE; ++FB) {
// get the list to work
// Worklist(LatticeDefinition, FB, LatticeDefinition.Top());
}
// we are not modifying the code so return False
return false;
}
};
}
char CPAnalysis::ID = 0;
static RegisterPass<CPAnalysis> X("constant-propagation-analysis", "Analyze all the functions in a module with a constant propagation lattice");