//
//===----------------------------------------------------------------------===//
+#define DEBUG_TYPE "adce"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Constants.h"
#include "llvm/Instructions.h"
#include <algorithm>
using namespace llvm;
-namespace {
- Statistic NumBlockRemoved("adce", "Number of basic blocks removed");
- Statistic NumInstRemoved ("adce", "Number of instructions removed");
- Statistic NumCallRemoved ("adce", "Number of calls and invokes removed");
+STATISTIC(NumBlockRemoved, "Number of basic blocks removed");
+STATISTIC(NumInstRemoved , "Number of instructions removed");
+STATISTIC(NumCallRemoved , "Number of calls and invokes removed");
+namespace {
//===----------------------------------------------------------------------===//
// ADCE Class
//
//
//===----------------------------------------------------------------------===//
+#define DEBUG_TYPE "block-placement"
#include "llvm/Analysis/ProfileInfo.h"
#include "llvm/Function.h"
#include "llvm/Pass.h"
#include <set>
using namespace llvm;
-namespace {
- Statistic NumMoved("block-placement", "Number of basic blocks moved");
+STATISTIC(NumMoved, "Number of basic blocks moved");
+namespace {
struct BlockPlacement : public FunctionPass {
virtual bool runOnFunction(Function &F);
#include "llvm/Support/Streams.h"
using namespace llvm;
-namespace {
- Statistic
- NumBrThread("condprop", "Number of CFG edges threaded through branches");
- Statistic
- NumSwThread("condprop", "Number of CFG edges threaded through switches");
+STATISTIC(NumBrThread, "Number of CFG edges threaded through branches");
+STATISTIC(NumSwThread, "Number of CFG edges threaded through switches");
+namespace {
struct CondProp : public FunctionPass {
virtual bool runOnFunction(Function &F);
//
//===----------------------------------------------------------------------===//
+#define DEBUG_TYPE "constprop"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Constant.h"
#include <set>
using namespace llvm;
-namespace {
- Statistic NumInstKilled("constprop", "Number of instructions killed");
+STATISTIC(NumInstKilled, "Number of instructions killed");
+namespace {
struct ConstantPropagation : public FunctionPass {
bool runOnFunction(Function &F);
//
//===----------------------------------------------------------------------===//
+#define DEBUG_TYPE "cee"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Constants.h"
#include "llvm/Pass.h"
#include <algorithm>
using namespace llvm;
-namespace {
- Statistic NumSetCCRemoved("cee", "Number of setcc instruction eliminated");
- Statistic NumOperandsCann("cee", "Number of operands canonicalized");
- Statistic BranchRevectors("cee", "Number of branches revectored");
+STATISTIC(NumSetCCRemoved, "Number of setcc instruction eliminated");
+STATISTIC(NumOperandsCann, "Number of operands canonicalized");
+STATISTIC(BranchRevectors, "Number of branches revectored");
+namespace {
class ValueInfo;
class Relation {
Value *Val; // Relation to what value?
//
//===----------------------------------------------------------------------===//
+#define DEBUG_TYPE "dce"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Instruction.h"
#include <set>
using namespace llvm;
-namespace {
- Statistic DIEEliminated("die", "Number of insts removed");
- Statistic DCEEliminated("dce", "Number of insts removed");
+STATISTIC(DIEEliminated, "Number of insts removed by DIE pass");
+STATISTIC(DCEEliminated, "Number of insts removed");
+namespace {
//===--------------------------------------------------------------------===//
// DeadInstElimination pass implementation
//
-
struct DeadInstElimination : public BasicBlockPass {
virtual bool runOnBasicBlock(BasicBlock &BB) {
bool Changed = false;
}
-//===----------------------------------------------------------------------===//
-// DeadCodeElimination pass implementation
-//
-
namespace {
+ //===--------------------------------------------------------------------===//
+ // DeadCodeElimination pass implementation
+ //
struct DCE : public FunctionPass {
virtual bool runOnFunction(Function &F);
//
//===----------------------------------------------------------------------===//
+#define DEBUG_TYPE "dse"
#include "llvm/Transforms/Scalar.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
#include "llvm/ADT/Statistic.h"
using namespace llvm;
-namespace {
- Statistic NumStores("dse", "Number of stores deleted");
- Statistic NumOther ("dse", "Number of other instrs removed");
+STATISTIC(NumStores, "Number of stores deleted");
+STATISTIC(NumOther , "Number of other instrs removed");
+namespace {
struct DSE : public FunctionPass {
virtual bool runOnFunction(Function &F) {
//
//===----------------------------------------------------------------------===//
+#define DEBUG_TYPE "gcse"
#include "llvm/Transforms/Scalar.h"
#include "llvm/BasicBlock.h"
#include "llvm/Constant.h"
#include <algorithm>
using namespace llvm;
+STATISTIC(NumInstRemoved, "Number of instructions removed");
+STATISTIC(NumLoadRemoved, "Number of loads removed");
+STATISTIC(NumCallRemoved, "Number of calls removed");
+STATISTIC(NumNonInsts , "Number of instructions removed due "
+ "to non-instruction values");
+STATISTIC(NumArgsRepl , "Number of function arguments replaced "
+ "with constant values");
namespace {
- Statistic NumInstRemoved("gcse", "Number of instructions removed");
- Statistic NumLoadRemoved("gcse", "Number of loads removed");
- Statistic NumCallRemoved("gcse", "Number of calls removed");
- Statistic NumNonInsts ("gcse", "Number of instructions removed due "
- "to non-instruction values");
- Statistic NumArgsRepl ("gcse", "Number of function arguments replaced "
- "with constant values");
-
struct GCSE : public FunctionPass {
virtual bool runOnFunction(Function &F);
//
//===----------------------------------------------------------------------===//
+#define DEBUG_TYPE "indvars"
#include "llvm/Transforms/Scalar.h"
#include "llvm/BasicBlock.h"
#include "llvm/Constants.h"
#include "llvm/ADT/Statistic.h"
using namespace llvm;
-namespace {
- Statistic NumRemoved ("indvars", "Number of aux indvars removed");
- Statistic NumPointer ("indvars", "Number of pointer indvars promoted");
- Statistic NumInserted("indvars", "Number of canonical indvars added");
- Statistic NumReplaced("indvars", "Number of exit values replaced");
- Statistic NumLFTR ("indvars", "Number of loop exit tests replaced");
+STATISTIC(NumRemoved , "Number of aux indvars removed");
+STATISTIC(NumPointer , "Number of pointer indvars promoted");
+STATISTIC(NumInserted, "Number of canonical indvars added");
+STATISTIC(NumReplaced, "Number of exit values replaced");
+STATISTIC(NumLFTR , "Number of loop exit tests replaced");
+namespace {
class IndVarSimplify : public FunctionPass {
LoopInfo *LI;
ScalarEvolution *SE;
using namespace llvm;
using namespace llvm::PatternMatch;
-namespace {
- Statistic NumCombined ("instcombine", "Number of insts combined");
- Statistic NumConstProp("instcombine", "Number of constant folds");
- Statistic NumDeadInst ("instcombine", "Number of dead inst eliminated");
- Statistic NumDeadStore("instcombine", "Number of dead stores eliminated");
- Statistic NumSunkInst ("instcombine", "Number of instructions sunk");
+STATISTIC(NumCombined , "Number of insts combined");
+STATISTIC(NumConstProp, "Number of constant folds");
+STATISTIC(NumDeadInst , "Number of dead inst eliminated");
+STATISTIC(NumDeadStore, "Number of dead stores eliminated");
+STATISTIC(NumSunkInst , "Number of instructions sunk");
+namespace {
class VISIBILITY_HIDDEN InstCombiner
: public FunctionPass,
public InstVisitor<InstCombiner, Instruction*> {
#include <algorithm>
using namespace llvm;
+STATISTIC(NumSunk , "Number of instructions sunk out of loop");
+STATISTIC(NumHoisted , "Number of instructions hoisted out of loop");
+STATISTIC(NumMovedLoads, "Number of load insts hoisted or sunk");
+STATISTIC(NumMovedCalls, "Number of call insts hoisted or sunk");
+STATISTIC(NumPromoted , "Number of memory locations promoted to registers");
+
namespace {
cl::opt<bool>
DisablePromotion("disable-licm-promotion", cl::Hidden,
cl::desc("Disable memory promotion in LICM pass"));
- Statistic NumSunk("licm", "Number of instructions sunk out of loop");
- Statistic NumHoisted("licm", "Number of instructions hoisted out of loop");
- Statistic NumMovedLoads("licm", "Number of load insts hoisted or sunk");
- Statistic NumMovedCalls("licm", "Number of call insts hoisted or sunk");
- Statistic NumPromoted("licm",
- "Number of memory locations promoted to registers");
-
struct LICM : public FunctionPass {
virtual bool runOnFunction(Function &F);
#include <set>
using namespace llvm;
-namespace {
- Statistic NumReduced ("loop-reduce", "Number of GEPs strength reduced");
- Statistic NumInserted("loop-reduce", "Number of PHIs inserted");
- Statistic NumVariable("loop-reduce","Number of PHIs with variable strides");
+STATISTIC(NumReduced , "Number of GEPs strength reduced");
+STATISTIC(NumInserted, "Number of PHIs inserted");
+STATISTIC(NumVariable, "Number of PHIs with variable strides");
+namespace {
/// IVStrideUse - Keep track of one use of a strided induction variable, where
/// the stride is stored externally. The Offset member keeps track of the
/// offset from the IV, User is the actual user of the operand, and 'Operand'
#include <algorithm>
using namespace llvm;
-namespace {
- Statistic NumUnrolled("loop-unroll", "Number of loops completely unrolled");
+STATISTIC(NumUnrolled, "Number of loops completely unrolled");
+namespace {
cl::opt<unsigned>
UnrollThreshold("unroll-threshold", cl::init(100), cl::Hidden,
cl::desc("The cut-off point for loop unrolling"));
#include <set>
using namespace llvm;
+STATISTIC(NumBranches, "Number of branches unswitched");
+STATISTIC(NumSwitches, "Number of switches unswitched");
+STATISTIC(NumSelects , "Number of selects unswitched");
+STATISTIC(NumTrivial , "Number of unswitches that are trivial");
+STATISTIC(NumSimplify, "Number of simplifications of unswitched code");
+
namespace {
- Statistic NumBranches("loop-unswitch", "Number of branches unswitched");
- Statistic NumSwitches("loop-unswitch", "Number of switches unswitched");
- Statistic NumSelects ("loop-unswitch", "Number of selects unswitched");
- Statistic NumTrivial ("loop-unswitch",
- "Number of unswitches that are trivial");
- Statistic NumSimplify("loop-unswitch",
- "Number of simplifications of unswitched code");
cl::opt<unsigned>
Threshold("loop-unswitch-threshold", cl::desc("Max loop size to unswitch"),
cl::init(10), cl::Hidden);
#include <algorithm>
using namespace llvm;
-namespace {
- Statistic NumLinear ("reassociate","Number of insts linearized");
- Statistic NumChanged("reassociate","Number of insts reassociated");
- Statistic NumSwapped("reassociate","Number of insts with operands swapped");
- Statistic NumAnnihil("reassociate","Number of expr tree annihilated");
- Statistic NumFactor ("reassociate","Number of multiplies factored");
+STATISTIC(NumLinear , "Number of insts linearized");
+STATISTIC(NumChanged, "Number of insts reassociated");
+STATISTIC(NumAnnihil, "Number of expr tree annihilated");
+STATISTIC(NumFactor , "Number of multiplies factored");
+namespace {
struct ValueEntry {
unsigned Rank;
Value *Op;
//
//===----------------------------------------------------------------------===//
+#define DEBUG_TYPE "reg2mem"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Pass.h"
#include "llvm/BasicBlock.h"
#include "llvm/Instructions.h"
#include "llvm/ADT/Statistic.h"
-
#include <list>
-
using namespace llvm;
+STATISTIC(NumDemoted, "Number of registers demoted");
+
namespace {
- Statistic NumDemoted("reg2mem", "Number of registers demoted");
-
struct RegToMem : public FunctionPass {
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
#include <set>
using namespace llvm;
+STATISTIC(NumInstRemoved, "Number of instructions removed");
+STATISTIC(NumDeadBlocks , "Number of basic blocks unreachable");
+
+STATISTIC(IPNumInstRemoved, "Number ofinstructions removed by IPSCCP");
+STATISTIC(IPNumDeadBlocks , "Number of basic blocks unreachable by IPSCCP");
+STATISTIC(IPNumArgsElimed ,"Number of arguments constant propagated by IPSCCP");
+STATISTIC(IPNumGlobalConst, "Number of globals found to be constant by IPSCCP");
+
+
+
// LatticeVal class - This class represents the different lattice values that an
// instruction may occupy. It is a simple class with value semantics.
//
namespace {
- Statistic NumInstRemoved("sccp", "Number of instructions removed");
- Statistic NumDeadBlocks ("sccp", "Number of basic blocks unreachable");
-
//===--------------------------------------------------------------------===//
//
/// SCCP Class - This class uses the SCCPSolver to implement a per-function
}
namespace {
- Statistic IPNumInstRemoved("ipsccp", "Number of instructions removed");
- Statistic IPNumDeadBlocks ("ipsccp", "Number of basic blocks unreachable");
- Statistic IPNumArgsElimed ("ipsccp",
- "Number of arguments constant propagated");
- Statistic IPNumGlobalConst("ipsccp",
- "Number of globals found to be constant");
-
//===--------------------------------------------------------------------===//
//
/// IPSCCP Class - This class implements interprocedural Sparse Conditional
//
//===----------------------------------------------------------------------===//
+#define DEBUG_TYPE "scalarrepl"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/ADT/StringExtras.h"
using namespace llvm;
-namespace {
- Statistic NumReplaced("scalarrepl", "Number of allocas broken up");
- Statistic NumPromoted("scalarrepl", "Number of allocas promoted");
- Statistic NumConverted("scalarrepl",
- "Number of aggregates converted to scalar");
+STATISTIC(NumReplaced, "Number of allocas broken up");
+STATISTIC(NumPromoted, "Number of allocas promoted");
+STATISTIC(NumConverted, "Number of aggregates converted to scalar");
+namespace {
struct VISIBILITY_HIDDEN SROA : public FunctionPass {
bool runOnFunction(Function &F);
//
//===----------------------------------------------------------------------===//
+#define DEBUG_TYPE "simplifycfg"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Constants.h"
#include <set>
using namespace llvm;
-namespace {
- Statistic NumSimpl("cfgsimplify", "Number of blocks simplified");
+STATISTIC(NumSimpl, "Number of blocks simplified");
+namespace {
struct CFGSimplifyPass : public FunctionPass {
virtual bool runOnFunction(Function &F);
};
#include "llvm/ADT/Statistic.h"
using namespace llvm;
+STATISTIC(NumEliminated, "Number of unconditional branches eliminated");
+
namespace {
cl::opt<unsigned>
Threshold("taildup-threshold", cl::desc("Max block size to tail duplicate"),
cl::init(6), cl::Hidden);
- Statistic NumEliminated("tailduplicate",
- "Number of unconditional branches eliminated");
- Statistic NumPHINodes("tailduplicate", "Number of phi nodes inserted");
-
class TailDup : public FunctionPass {
bool runOnFunction(Function &F);
private:
//
//===----------------------------------------------------------------------===//
+#define DEBUG_TYPE "tailcallelim"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/ADT/Statistic.h"
using namespace llvm;
-namespace {
- Statistic NumEliminated("tailcallelim", "Number of tail calls removed");
- Statistic NumAccumAdded("tailcallelim","Number of accumulators introduced");
+STATISTIC(NumEliminated, "Number of tail calls removed");
+STATISTIC(NumAccumAdded, "Number of accumulators introduced");
+namespace {
struct TailCallElim : public FunctionPass {
virtual bool runOnFunction(Function &F);