Eliminate static ctors due to Statistic objects

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32693 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2006-12-19 22:09:18 +00:00
parent 438e08e357
commit 86453c52ba
16 changed files with 71 additions and 85 deletions

View File

@@ -47,14 +47,11 @@
#include <set> #include <set>
using namespace llvm; using namespace llvm;
namespace { STATISTIC(NumArgumentsPromoted , "Number of pointer arguments promoted");
Statistic NumArgumentsPromoted("argpromotion", STATISTIC(NumAggregatesPromoted, "Number of aggregate arguments promoted");
"Number of pointer arguments promoted"); STATISTIC(NumArgumentsDead , "Number of dead pointer args eliminated");
Statistic NumAggregatesPromoted("argpromotion",
"Number of aggregate arguments promoted");
Statistic NumArgumentsDead("argpromotion",
"Number of dead pointer args eliminated");
namespace {
/// ArgPromotion - The 'by reference' to 'by value' argument promotion pass. /// ArgPromotion - The 'by reference' to 'by value' argument promotion pass.
/// ///
struct ArgPromotion : public CallGraphSCCPass { struct ArgPromotion : public CallGraphSCCPass {

View File

@@ -17,15 +17,16 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#define DEBUG_TYPE "constmerge"
#include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO.h"
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/Pass.h" #include "llvm/Pass.h"
#include "llvm/ADT/Statistic.h" #include "llvm/ADT/Statistic.h"
using namespace llvm; using namespace llvm;
namespace { STATISTIC(NumMerged, "Number of global constants merged");
Statistic NumMerged("constmerge", "Number of global constants merged");
namespace {
struct ConstantMerge : public ModulePass { struct ConstantMerge : public ModulePass {
// run - For this pass, process all of the globals in the module, // run - For this pass, process all of the globals in the module,
// eliminating duplicate constants. // eliminating duplicate constants.

View File

@@ -32,12 +32,10 @@
#include <set> #include <set>
using namespace llvm; using namespace llvm;
namespace { STATISTIC(NumArgumentsEliminated, "Number of unread args removed");
Statistic NumArgumentsEliminated("deadargelim", STATISTIC(NumRetValsEliminated , "Number of unused return values removed");
"Number of unread args removed");
Statistic NumRetValsEliminated("deadargelim",
"Number of unused return values removed");
namespace {
/// DAE - The dead argument elimination pass. /// DAE - The dead argument elimination pass.
/// ///
class DAE : public ModulePass { class DAE : public ModulePass {

View File

@@ -12,6 +12,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#define DEBUG_TYPE "deadtypeelim"
#include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO.h"
#include "llvm/Analysis/FindUsedTypes.h" #include "llvm/Analysis/FindUsedTypes.h"
#include "llvm/Module.h" #include "llvm/Module.h"
@@ -20,6 +21,8 @@
#include "llvm/ADT/Statistic.h" #include "llvm/ADT/Statistic.h"
using namespace llvm; using namespace llvm;
STATISTIC(NumKilled, "Number of unused typenames removed from symtab");
namespace { namespace {
struct DTE : public ModulePass { struct DTE : public ModulePass {
// doPassInitialization - For this pass, it removes global symbol table // doPassInitialization - For this pass, it removes global symbol table
@@ -37,8 +40,6 @@ namespace {
} }
}; };
RegisterPass<DTE> X("deadtypeelim", "Dead Type Elimination"); RegisterPass<DTE> X("deadtypeelim", "Dead Type Elimination");
Statistic
NumKilled("deadtypeelim", "Number of unused typenames removed from symtab");
} }
ModulePass *llvm::createDeadTypeEliminationPass() { ModulePass *llvm::createDeadTypeEliminationPass() {

View File

@@ -18,6 +18,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#define DEBUG_TYPE "funcresolve"
#include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO.h"
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
@@ -31,10 +32,10 @@
#include <algorithm> #include <algorithm>
using namespace llvm; using namespace llvm;
namespace { STATISTIC(NumResolved, "Number of varargs functions resolved");
Statistic NumResolved("funcresolve", "Number of varargs functions resolved"); STATISTIC(NumGlobals, "Number of global variables resolved");
Statistic NumGlobals("funcresolve", "Number of global variables resolved");
namespace {
struct FunctionResolvingPass : public ModulePass { struct FunctionResolvingPass : public ModulePass {
virtual void getAnalysisUsage(AnalysisUsage &AU) const { virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<TargetData>(); AU.addRequired<TargetData>();

View File

@@ -15,6 +15,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#define DEBUG_TYPE "globaldce"
#include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO.h"
#include "llvm/Constants.h" #include "llvm/Constants.h"
#include "llvm/Module.h" #include "llvm/Module.h"
@@ -23,10 +24,10 @@
#include <set> #include <set>
using namespace llvm; using namespace llvm;
namespace { STATISTIC(NumFunctions, "Number of functions removed");
Statistic NumFunctions("globaldce","Number of functions removed"); STATISTIC(NumVariables, "Number of global variables removed");
Statistic NumVariables("globaldce","Number of global variables removed");
namespace {
struct GlobalDCE : public ModulePass { struct GlobalDCE : public ModulePass {
// run - Do the GlobalDCE pass on the specified module, optionally updating // run - Do the GlobalDCE pass on the specified module, optionally updating
// the specified callgraph to reflect the changes. // the specified callgraph to reflect the changes.

View File

@@ -31,23 +31,19 @@
#include <set> #include <set>
using namespace llvm; using namespace llvm;
namespace { STATISTIC(NumMarked , "Number of globals marked constant");
Statistic NumMarked ("globalopt", "Number of globals marked constant"); STATISTIC(NumSRA , "Number of aggregate globals broken into scalars");
Statistic NumSRA ("globalopt", "Number of aggregate globals broken " STATISTIC(NumHeapSRA , "Number of heap objects SRA'd");
"into scalars"); STATISTIC(NumSubstitute,"Number of globals with initializers stored into them");
Statistic NumHeapSRA ("globalopt", "Number of heap objects SRA'd"); STATISTIC(NumDeleted , "Number of globals deleted");
Statistic NumSubstitute("globalopt", STATISTIC(NumFnDeleted , "Number of functions deleted");
"Number of globals with initializers stored into them"); STATISTIC(NumGlobUses , "Number of global uses devirtualized");
Statistic NumDeleted ("globalopt", "Number of globals deleted"); STATISTIC(NumLocalized , "Number of globals localized");
Statistic NumFnDeleted("globalopt", "Number of functions deleted"); STATISTIC(NumShrunkToBool , "Number of global vars shrunk to booleans");
Statistic NumGlobUses ("globalopt", "Number of global uses devirtualized"); STATISTIC(NumFastCallFns , "Number of functions converted to fastcc");
Statistic NumLocalized("globalopt", "Number of globals localized"); STATISTIC(NumCtorsEvaluated, "Number of static ctors evaluated");
Statistic NumShrunkToBool("globalopt",
"Number of global vars shrunk to booleans");
Statistic NumFastCallFns("globalopt",
"Number of functions converted to fastcc");
Statistic NumCtorsEvaluated("globalopt","Number of static ctors evaluated");
namespace {
struct GlobalOpt : public ModulePass { struct GlobalOpt : public ModulePass {
virtual void getAnalysisUsage(AnalysisUsage &AU) const { virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<TargetData>(); AU.addRequired<TargetData>();

View File

@@ -15,6 +15,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#define DEBUG_TYPE "ipconstprop"
#include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO.h"
#include "llvm/Constants.h" #include "llvm/Constants.h"
#include "llvm/Instructions.h" #include "llvm/Instructions.h"
@@ -24,12 +25,10 @@
#include "llvm/ADT/Statistic.h" #include "llvm/ADT/Statistic.h"
using namespace llvm; using namespace llvm;
namespace { STATISTIC(NumArgumentsProped, "Number of args turned into constants");
Statistic NumArgumentsProped("ipconstprop", STATISTIC(NumReturnValProped, "Number of return values turned into constants");
"Number of args turned into constants");
Statistic NumReturnValProped("ipconstprop",
"Number of return values turned into constants");
namespace {
/// IPCP - The interprocedural constant propagation pass /// IPCP - The interprocedural constant propagation pass
/// ///
struct IPCP : public ModulePass { struct IPCP : public ModulePass {

View File

@@ -15,36 +15,27 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#define DEBUG_TYPE "indmemrem"
#include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO.h"
#include "llvm/Pass.h" #include "llvm/Pass.h"
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/Function.h"
#include "llvm/Instructions.h" #include "llvm/Instructions.h"
#include "llvm/Type.h" #include "llvm/Type.h"
#include "llvm/Support/Debug.h"
#include "llvm/ADT/Statistic.h" #include "llvm/ADT/Statistic.h"
#include <fstream>
#include <set>
using namespace llvm; using namespace llvm;
STATISTIC(NumBounceSites, "Number of sites modified");
STATISTIC(NumBounce , "Number of bounce functions created");
namespace { namespace {
Statistic NumBounceSites("indmemrem", "Number of sites modified");
Statistic NumBounce ("indmemrem", "Number of bounce functions created");
class IndMemRemPass : public ModulePass { class IndMemRemPass : public ModulePass {
public: public:
IndMemRemPass();
virtual bool runOnModule(Module &M); virtual bool runOnModule(Module &M);
}; };
RegisterPass<IndMemRemPass> X("indmemrem","Indirect Malloc and Free Removal"); RegisterPass<IndMemRemPass> X("indmemrem","Indirect Malloc and Free Removal");
} // end anonymous namespace } // end anonymous namespace
IndMemRemPass::IndMemRemPass()
{
}
bool IndMemRemPass::runOnModule(Module &M) { bool IndMemRemPass::runOnModule(Module &M) {
//in Theory, all direct calls of malloc and free should be promoted //in Theory, all direct calls of malloc and free should be promoted
//to intrinsics. Therefor, this goes through and finds where the //to intrinsics. Therefor, this goes through and finds where the

View File

@@ -13,6 +13,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#define DEBUG_TYPE "inline"
#include "Inliner.h" #include "Inliner.h"
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/Instructions.h" #include "llvm/Instructions.h"
@@ -25,10 +26,10 @@
#include <set> #include <set>
using namespace llvm; using namespace llvm;
STATISTIC(NumInlined, "Number of functions inlined");
STATISTIC(NumDeleted, "Number of functions deleted because all callers found");
namespace { namespace {
Statistic NumInlined("inline", "Number of functions inlined");
Statistic NumDeleted("inline",
"Number of functions deleted because all callers found");
cl::opt<unsigned> // FIXME: 200 is VERY conservative cl::opt<unsigned> // FIXME: 200 is VERY conservative
InlineLimit("inline-threshold", cl::Hidden, cl::init(200), InlineLimit("inline-threshold", cl::Hidden, cl::init(200),
cl::desc("Control the amount of inlining to perform (default = 200)")); cl::desc("Control the amount of inlining to perform (default = 200)"));

View File

@@ -13,6 +13,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#define DEBUG_TYPE "internalize"
#include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO.h"
#include "llvm/Pass.h" #include "llvm/Pass.h"
#include "llvm/Module.h" #include "llvm/Module.h"
@@ -23,9 +24,10 @@
#include <set> #include <set>
using namespace llvm; using namespace llvm;
STATISTIC(NumFunctions, "Number of functions internalized");
STATISTIC(NumGlobals , "Number of global vars internalized");
namespace { namespace {
Statistic NumFunctions("internalize", "Number of functions internalized");
Statistic NumGlobals ("internalize", "Number of global vars internalized");
// APIFile - A file which contains a list of symbols that should not be marked // APIFile - A file which contains a list of symbols that should not be marked
// external. // external.

View File

@@ -14,6 +14,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#define DEBUG_TYPE "loop-extract"
#include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO.h"
#include "llvm/Instructions.h" #include "llvm/Instructions.h"
#include "llvm/Module.h" #include "llvm/Module.h"
@@ -25,9 +26,9 @@
#include "llvm/ADT/Statistic.h" #include "llvm/ADT/Statistic.h"
using namespace llvm; using namespace llvm;
namespace { STATISTIC(NumExtracted, "Number of loops extracted");
Statistic NumExtracted("loop-extract", "Number of loops extracted");
namespace {
// FIXME: This is not a function pass, but the PassManager doesn't allow // FIXME: This is not a function pass, but the PassManager doesn't allow
// Module passes to require FunctionPasses, so we can't get loop info if we're // Module passes to require FunctionPasses, so we can't get loop info if we're
// not a function pass. // not a function pass.

View File

@@ -33,6 +33,7 @@
// pass invokable via the "opt" command at will. // pass invokable via the "opt" command at will.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#define DEBUG_TYPE "lowersetjmp"
#include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO.h"
#include "llvm/Constants.h" #include "llvm/Constants.h"
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
@@ -49,16 +50,12 @@
#include "llvm/ADT/VectorExtras.h" #include "llvm/ADT/VectorExtras.h"
using namespace llvm; using namespace llvm;
namespace { STATISTIC(LongJmpsTransformed, "Number of longjmps transformed");
Statistic LongJmpsTransformed("lowersetjmp", STATISTIC(SetJmpsTransformed , "Number of setjmps transformed");
"Number of longjmps transformed"); STATISTIC(CallsTransformed , "Number of calls invokified");
Statistic SetJmpsTransformed("lowersetjmp", STATISTIC(InvokesTransformed , "Number of invokes modified");
"Number of setjmps transformed");
Statistic CallsTransformed("lowersetjmp",
"Number of calls invokified");
Statistic InvokesTransformed("lowersetjmp",
"Number of invokes modified");
namespace {
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// LowerSetJmp pass implementation. // LowerSetJmp pass implementation.
class LowerSetJmp : public ModulePass, class LowerSetJmp : public ModulePass,

View File

@@ -14,6 +14,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#define DEBUG_TYPE "prune-eh"
#include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO.h"
#include "llvm/CallGraphSCCPass.h" #include "llvm/CallGraphSCCPass.h"
#include "llvm/Constants.h" #include "llvm/Constants.h"
@@ -27,10 +28,10 @@
#include <algorithm> #include <algorithm>
using namespace llvm; using namespace llvm;
namespace { STATISTIC(NumRemoved, "Number of invokes removed");
Statistic NumRemoved("prune-eh", "Number of invokes removed"); STATISTIC(NumUnreach, "Number of noreturn calls optimized");
Statistic NumUnreach("prune-eh", "Number of noreturn calls optimized");
namespace {
struct PruneEH : public CallGraphSCCPass { struct PruneEH : public CallGraphSCCPass {
/// DoesNotUnwind - This set contains all of the functions which we have /// DoesNotUnwind - This set contains all of the functions which we have
/// determined cannot unwind. /// determined cannot unwind.

View File

@@ -12,6 +12,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#define DEBUG_TYPE "raiseallocs"
#include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO.h"
#include "llvm/Constants.h" #include "llvm/Constants.h"
#include "llvm/DerivedTypes.h" #include "llvm/DerivedTypes.h"
@@ -22,9 +23,9 @@
#include "llvm/ADT/Statistic.h" #include "llvm/ADT/Statistic.h"
using namespace llvm; using namespace llvm;
namespace { STATISTIC(NumRaised, "Number of allocations raised");
Statistic NumRaised("raiseallocs", "Number of allocations raised");
namespace {
// RaiseAllocations - Turn %malloc and %free calls into the appropriate // RaiseAllocations - Turn %malloc and %free calls into the appropriate
// instruction. // instruction.
// //

View File

@@ -31,17 +31,15 @@
#include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO.h"
using namespace llvm; using namespace llvm;
namespace {
/// This statistic keeps track of the total number of library calls that have /// This statistic keeps track of the total number of library calls that have
/// been simplified regardless of which call it is. /// been simplified regardless of which call it is.
Statistic SimplifiedLibCalls("simplify-libcalls", STATISTIC(SimplifiedLibCalls, "Number of library calls simplified");
"Number of library calls simplified");
// Forward declarations
class LibCallOptimization;
class SimplifyLibCalls;
namespace {
// Forward declarations
class LibCallOptimization;
class SimplifyLibCalls;
/// This list is populated by the constructor for LibCallOptimization class. /// This list is populated by the constructor for LibCallOptimization class.
/// Therefore all subclasses are registered here at static initialization time /// Therefore all subclasses are registered here at static initialization time
/// and this list is what the SimplifyLibCalls pass uses to apply the individual /// and this list is what the SimplifyLibCalls pass uses to apply the individual