Commit 3dd5de267ae8650b168f3a856b21f639d3283480

Authored by Yoshiki Vazquez-baeza
1 parent 3c0f7cc60d
Exists in master

Add constant propagation pass file

Showing 1 changed file with 53 additions and 0 deletions Inline Diff

llvm/src/lib/CSE231/CPAnalysis.cpp View file @ 3dd5de2
File was created 1 //===- CPAnalysis.cpp
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the constant propagation analysis.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/ADT/StringMap.h"
15 #include "llvm/ADT/DenseMap.h"
16 #include "llvm/IR/Function.h"
17 #include "llvm/IR/Module.h"
18 #include "llvm/IR/BasicBlock.h"
19 #include "llvm/IR/Instruction.h"
20 #include "llvm/Pass.h"
21 #include "llvm/Support/raw_ostream.h"
22 #include "llvm/Support/InstIterator.h"
23 using namespace llvm;
24
25 namespace {
26
27 struct CPAnalysis : public ModulePass {
28 static char ID;
29
30 CPAnalysis() : ModulePass(ID) {}
31
32 virtual bool runOnModule(Module &M) {
33 unsigned opcode;
34 IRBuilder<> builder(M.getContext());
35
36 // Iterating over all the functions in the module
37 for (Module::iterator FB = M.begin(), FE = M.end(); FB != FE; ++FB) {
38
39 // get the list to work
40 // Worklist(LatticeDefinition, FB, LatticeDefinition.Top());
41