Deleted Added
full compact
IPConstantPropagation.cpp (198090) IPConstantPropagation.cpp (198892)
1//===-- IPConstantPropagation.cpp - Propagate constants through calls -----===//
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//===----------------------------------------------------------------------===//

--- 10 unchanged lines hidden (view full) ---

19#include "llvm/Transforms/IPO.h"
20#include "llvm/Constants.h"
21#include "llvm/Instructions.h"
22#include "llvm/LLVMContext.h"
23#include "llvm/Module.h"
24#include "llvm/Pass.h"
25#include "llvm/Analysis/ValueTracking.h"
26#include "llvm/Support/CallSite.h"
1//===-- IPConstantPropagation.cpp - Propagate constants through calls -----===//
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//===----------------------------------------------------------------------===//

--- 10 unchanged lines hidden (view full) ---

19#include "llvm/Transforms/IPO.h"
20#include "llvm/Constants.h"
21#include "llvm/Instructions.h"
22#include "llvm/LLVMContext.h"
23#include "llvm/Module.h"
24#include "llvm/Pass.h"
25#include "llvm/Analysis/ValueTracking.h"
26#include "llvm/Support/CallSite.h"
27#include "llvm/Support/Compiler.h"
28#include "llvm/ADT/Statistic.h"
29#include "llvm/ADT/SmallVector.h"
30using namespace llvm;
31
32STATISTIC(NumArgumentsProped, "Number of args turned into constants");
33STATISTIC(NumReturnValProped, "Number of return values turned into constants");
34
35namespace {
36 /// IPCP - The interprocedural constant propagation pass
37 ///
27#include "llvm/ADT/Statistic.h"
28#include "llvm/ADT/SmallVector.h"
29using namespace llvm;
30
31STATISTIC(NumArgumentsProped, "Number of args turned into constants");
32STATISTIC(NumReturnValProped, "Number of return values turned into constants");
33
34namespace {
35 /// IPCP - The interprocedural constant propagation pass
36 ///
38 struct VISIBILITY_HIDDEN IPCP : public ModulePass {
37 struct IPCP : public ModulePass {
39 static char ID; // Pass identification, replacement for typeid
40 IPCP() : ModulePass(&ID) {}
41
42 bool runOnModule(Module &M);
43 private:
44 bool PropagateConstantsIntoArguments(Function &F);
45 bool PropagateConstantReturn(Function &F);
46 };

--- 35 unchanged lines hidden (view full) ---

82
83 // For each argument, keep track of its constant value and whether it is a
84 // constant or not. The bool is driven to true when found to be non-constant.
85 SmallVector<std::pair<Constant*, bool>, 16> ArgumentConstants;
86 ArgumentConstants.resize(F.arg_size());
87
88 unsigned NumNonconstant = 0;
89 for (Value::use_iterator UI = F.use_begin(), E = F.use_end(); UI != E; ++UI) {
38 static char ID; // Pass identification, replacement for typeid
39 IPCP() : ModulePass(&ID) {}
40
41 bool runOnModule(Module &M);
42 private:
43 bool PropagateConstantsIntoArguments(Function &F);
44 bool PropagateConstantReturn(Function &F);
45 };

--- 35 unchanged lines hidden (view full) ---

81
82 // For each argument, keep track of its constant value and whether it is a
83 // constant or not. The bool is driven to true when found to be non-constant.
84 SmallVector<std::pair<Constant*, bool>, 16> ArgumentConstants;
85 ArgumentConstants.resize(F.arg_size());
86
87 unsigned NumNonconstant = 0;
88 for (Value::use_iterator UI = F.use_begin(), E = F.use_end(); UI != E; ++UI) {
89 // Ignore blockaddress uses.
90 if (isa<BlockAddress>(*UI)) continue;
91
90 // Used by a non-instruction, or not the callee of a function, do not
91 // transform.
92 if (!isa<CallInst>(*UI) && !isa<InvokeInst>(*UI))
93 return false;
94
95 CallSite CS = CallSite::get(cast<Instruction>(*UI));
96 if (!CS.isCallee(UI))
97 return false;

--- 180 unchanged lines hidden ---
92 // Used by a non-instruction, or not the callee of a function, do not
93 // transform.
94 if (!isa<CallInst>(*UI) && !isa<InvokeInst>(*UI))
95 return false;
96
97 CallSite CS = CallSite::get(cast<Instruction>(*UI));
98 if (!CS.isCallee(UI))
99 return false;

--- 180 unchanged lines hidden ---