mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Do not use typeinfo to identify pass in pass manager.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36632 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -63,12 +63,16 @@ namespace {
|
||||
}
|
||||
|
||||
virtual bool runOnSCC(const std::vector<CallGraphNode *> &SCC);
|
||||
static const int ID; // Pass identifcation, replacement for typeid
|
||||
ArgPromotion() : CallGraphSCCPass((intptr_t)&ID) {}
|
||||
|
||||
private:
|
||||
bool PromoteArguments(CallGraphNode *CGN);
|
||||
bool isSafeToPromoteArgument(Argument *Arg) const;
|
||||
Function *DoPromotion(Function *F, std::vector<Argument*> &ArgsToPromote);
|
||||
};
|
||||
|
||||
const int ArgPromotion::ID = 0;
|
||||
RegisterPass<ArgPromotion> X("argpromotion",
|
||||
"Promote 'by reference' arguments to scalars");
|
||||
}
|
||||
|
@@ -29,12 +29,16 @@ STATISTIC(NumMerged, "Number of global constants merged");
|
||||
|
||||
namespace {
|
||||
struct VISIBILITY_HIDDEN ConstantMerge : public ModulePass {
|
||||
static const int ID; // Pass identifcation, replacement for typeid
|
||||
ConstantMerge() : ModulePass((intptr_t)&ID) {}
|
||||
|
||||
// run - For this pass, process all of the globals in the module,
|
||||
// eliminating duplicate constants.
|
||||
//
|
||||
bool runOnModule(Module &M);
|
||||
};
|
||||
|
||||
const int ConstantMerge::ID = 0;
|
||||
RegisterPass<ConstantMerge>X("constmerge","Merge Duplicate Global Constants");
|
||||
}
|
||||
|
||||
|
@@ -76,6 +76,8 @@ namespace {
|
||||
std::multimap<Function*, CallSite> CallSites;
|
||||
|
||||
public:
|
||||
static const int ID; // Pass identifcation, replacement for typeid
|
||||
DAE() : ModulePass((intptr_t)&ID) {}
|
||||
bool runOnModule(Module &M);
|
||||
|
||||
virtual bool ShouldHackArguments() const { return false; }
|
||||
@@ -93,14 +95,17 @@ namespace {
|
||||
|
||||
void RemoveDeadArgumentsFromFunction(Function *F);
|
||||
};
|
||||
const int DAE::ID = 0;
|
||||
RegisterPass<DAE> X("deadargelim", "Dead Argument Elimination");
|
||||
|
||||
/// DAH - DeadArgumentHacking pass - Same as dead argument elimination, but
|
||||
/// deletes arguments to functions which are external. This is only for use
|
||||
/// by bugpoint.
|
||||
struct DAH : public DAE {
|
||||
static const int ID;
|
||||
virtual bool ShouldHackArguments() const { return true; }
|
||||
};
|
||||
const int DAH::ID = 0;
|
||||
RegisterPass<DAH> Y("deadarghaX0r",
|
||||
"Dead Argument Hacking (BUGPOINT USE ONLY; DO NOT USE)");
|
||||
}
|
||||
|
@@ -26,6 +26,9 @@ STATISTIC(NumKilled, "Number of unused typenames removed from symtab");
|
||||
|
||||
namespace {
|
||||
struct VISIBILITY_HIDDEN DTE : public ModulePass {
|
||||
static const int ID; // Pass identifcation, replacement for typeid
|
||||
DTE() : ModulePass((intptr_t)&ID) {}
|
||||
|
||||
// doPassInitialization - For this pass, it removes global symbol table
|
||||
// entries for primitive types. These are never used for linking in GCC and
|
||||
// they make the output uglier to look at, so we nuke them.
|
||||
@@ -40,6 +43,7 @@ namespace {
|
||||
AU.addRequired<FindUsedTypes>();
|
||||
}
|
||||
};
|
||||
const int DTE::ID = 0;
|
||||
RegisterPass<DTE> X("deadtypeelim", "Dead Type Elimination");
|
||||
}
|
||||
|
||||
|
@@ -25,13 +25,16 @@ namespace {
|
||||
bool deleteFunc;
|
||||
bool reLink;
|
||||
public:
|
||||
static const int ID; // Pass identifcation, replacement for typeid
|
||||
|
||||
/// FunctionExtractorPass - If deleteFn is true, this pass deletes as the
|
||||
/// specified function. Otherwise, it deletes as much of the module as
|
||||
/// possible, except for the function specified.
|
||||
///
|
||||
FunctionExtractorPass(Function *F = 0, bool deleteFn = true,
|
||||
bool relinkCallees = false)
|
||||
: Named(F), deleteFunc(deleteFn), reLink(relinkCallees) {}
|
||||
: ModulePass((intptr_t)&ID), Named(F), deleteFunc(deleteFn),
|
||||
reLink(relinkCallees) {}
|
||||
|
||||
bool runOnModule(Module &M) {
|
||||
if (Named == 0) {
|
||||
@@ -131,6 +134,7 @@ namespace {
|
||||
}
|
||||
};
|
||||
|
||||
const int FunctionExtractorPass::ID = 0;
|
||||
RegisterPass<FunctionExtractorPass> X("extract", "Function Extractor");
|
||||
}
|
||||
|
||||
|
@@ -30,6 +30,9 @@ STATISTIC(NumVariables, "Number of global variables removed");
|
||||
|
||||
namespace {
|
||||
struct VISIBILITY_HIDDEN GlobalDCE : public ModulePass {
|
||||
static const int ID; // Pass identifcation, replacement for typeid
|
||||
GlobalDCE() : ModulePass((intptr_t)&ID) {}
|
||||
|
||||
// run - Do the GlobalDCE pass on the specified module, optionally updating
|
||||
// the specified callgraph to reflect the changes.
|
||||
//
|
||||
@@ -46,6 +49,7 @@ namespace {
|
||||
bool SafeToDestroyConstant(Constant* C);
|
||||
bool RemoveUnusedGlobalValue(GlobalValue &GV);
|
||||
};
|
||||
const int GlobalDCE::ID = 0;
|
||||
RegisterPass<GlobalDCE> X("globaldce", "Dead Global Elimination");
|
||||
}
|
||||
|
||||
|
@@ -50,6 +50,8 @@ namespace {
|
||||
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.addRequired<TargetData>();
|
||||
}
|
||||
static const int ID; // Pass identifcation, replacement for typeid
|
||||
GlobalOpt() : ModulePass((intptr_t)&ID) {}
|
||||
|
||||
bool runOnModule(Module &M);
|
||||
|
||||
@@ -61,6 +63,7 @@ namespace {
|
||||
bool ProcessInternalGlobal(GlobalVariable *GV,Module::global_iterator &GVI);
|
||||
};
|
||||
|
||||
const int GlobalOpt::ID = 0;
|
||||
RegisterPass<GlobalOpt> X("globalopt", "Global Variable Optimizer");
|
||||
}
|
||||
|
||||
|
@@ -33,11 +33,15 @@ namespace {
|
||||
/// IPCP - The interprocedural constant propagation pass
|
||||
///
|
||||
struct VISIBILITY_HIDDEN IPCP : public ModulePass {
|
||||
static const int ID; // Pass identifcation, replacement for typeid
|
||||
IPCP() : ModulePass((intptr_t)&ID) {}
|
||||
|
||||
bool runOnModule(Module &M);
|
||||
private:
|
||||
bool PropagateConstantsIntoArguments(Function &F);
|
||||
bool PropagateConstantReturn(Function &F);
|
||||
};
|
||||
const int IPCP::ID = 0;
|
||||
RegisterPass<IPCP> X("ipconstprop", "Interprocedural constant propagation");
|
||||
}
|
||||
|
||||
|
@@ -32,8 +32,12 @@ STATISTIC(NumBounce , "Number of bounce functions created");
|
||||
namespace {
|
||||
class VISIBILITY_HIDDEN IndMemRemPass : public ModulePass {
|
||||
public:
|
||||
static const int ID; // Pass identifcation, replacement for typeid
|
||||
IndMemRemPass() : ModulePass((intptr_t)&ID) {}
|
||||
|
||||
virtual bool runOnModule(Module &M);
|
||||
};
|
||||
const int IndMemRemPass::ID = 0;
|
||||
RegisterPass<IndMemRemPass> X("indmemrem","Indirect Malloc and Free Removal");
|
||||
} // end anonymous namespace
|
||||
|
||||
|
@@ -54,8 +54,10 @@ namespace {
|
||||
class VISIBILITY_HIDDEN SimpleInliner : public Inliner {
|
||||
std::map<const Function*, FunctionInfo> CachedFunctionInfo;
|
||||
public:
|
||||
static const int ID; // Pass identifcation, replacement for typeid
|
||||
int getInlineCost(CallSite CS);
|
||||
};
|
||||
const int SimpleInliner::ID = 0;
|
||||
RegisterPass<SimpleInliner> X("inline", "Function Integration/Inlining");
|
||||
}
|
||||
|
||||
|
@@ -36,7 +36,9 @@ namespace {
|
||||
cl::desc("Control the amount of inlining to perform (default = 200)"));
|
||||
}
|
||||
|
||||
Inliner::Inliner() : InlineThreshold(InlineLimit) {}
|
||||
const int Inliner::ID = 0;
|
||||
Inliner::Inliner()
|
||||
: CallGraphSCCPass((intptr_t)&ID), InlineThreshold(InlineLimit) {}
|
||||
|
||||
/// getAnalysisUsage - For this class, we declare that we require and preserve
|
||||
/// the call graph. If the derived class implements this method, it should
|
||||
|
@@ -27,6 +27,7 @@ namespace llvm {
|
||||
/// perform the inlining operations that does not depend on the policy.
|
||||
///
|
||||
struct Inliner : public CallGraphSCCPass {
|
||||
static const int ID;
|
||||
Inliner();
|
||||
|
||||
/// getAnalysisUsage - For this class, we declare that we require and preserve
|
||||
|
@@ -46,16 +46,18 @@ namespace {
|
||||
std::set<std::string> ExternalNames;
|
||||
bool DontInternalize;
|
||||
public:
|
||||
static const int ID; // Pass identifcation, replacement for typeid
|
||||
InternalizePass(bool InternalizeEverything = true);
|
||||
InternalizePass(const std::vector <const char *>& exportList);
|
||||
void LoadFile(const char *Filename);
|
||||
virtual bool runOnModule(Module &M);
|
||||
};
|
||||
const int InternalizePass::ID = 0;
|
||||
RegisterPass<InternalizePass> X("internalize", "Internalize Global Symbols");
|
||||
} // end anonymous namespace
|
||||
|
||||
InternalizePass::InternalizePass(bool InternalizeEverything)
|
||||
: DontInternalize(false){
|
||||
: ModulePass((intptr_t)&ID), DontInternalize(false){
|
||||
if (!APIFile.empty()) // If a filename is specified, use it
|
||||
LoadFile(APIFile.c_str());
|
||||
else if (!APIList.empty()) // Else, if a list is specified, use it.
|
||||
@@ -66,7 +68,7 @@ InternalizePass::InternalizePass(bool InternalizeEverything)
|
||||
}
|
||||
|
||||
InternalizePass::InternalizePass(const std::vector<const char *>&exportList)
|
||||
: DontInternalize(false){
|
||||
: ModulePass((intptr_t)&ID), DontInternalize(false){
|
||||
for(std::vector<const char *>::const_iterator itr = exportList.begin();
|
||||
itr != exportList.end(); itr++) {
|
||||
ExternalNames.insert(*itr);
|
||||
|
@@ -34,9 +34,11 @@ namespace {
|
||||
// Module passes to require FunctionPasses, so we can't get loop info if we're
|
||||
// not a function pass.
|
||||
struct VISIBILITY_HIDDEN LoopExtractor : public FunctionPass {
|
||||
static const int ID; // Pass identifcation, replacement for typeid
|
||||
unsigned NumLoops;
|
||||
|
||||
LoopExtractor(unsigned numLoops = ~0) : NumLoops(numLoops) {}
|
||||
LoopExtractor(unsigned numLoops = ~0)
|
||||
: FunctionPass((intptr_t)&ID), NumLoops(numLoops) {}
|
||||
|
||||
virtual bool runOnFunction(Function &F);
|
||||
|
||||
@@ -49,14 +51,17 @@ namespace {
|
||||
}
|
||||
};
|
||||
|
||||
const int LoopExtractor::ID = 0;
|
||||
RegisterPass<LoopExtractor>
|
||||
X("loop-extract", "Extract loops into new functions");
|
||||
|
||||
/// SingleLoopExtractor - For bugpoint.
|
||||
struct SingleLoopExtractor : public LoopExtractor {
|
||||
static const int ID; // Pass identifcation, replacement for typeid
|
||||
SingleLoopExtractor() : LoopExtractor(1) {}
|
||||
};
|
||||
|
||||
const int SingleLoopExtractor::ID = 0;
|
||||
RegisterPass<SingleLoopExtractor>
|
||||
Y("loop-extract-single", "Extract at most one loop into a new function");
|
||||
} // End anonymous namespace
|
||||
@@ -147,11 +152,15 @@ namespace {
|
||||
class BlockExtractorPass : public ModulePass {
|
||||
std::vector<BasicBlock*> BlocksToNotExtract;
|
||||
public:
|
||||
BlockExtractorPass(std::vector<BasicBlock*> &B) : BlocksToNotExtract(B) {}
|
||||
BlockExtractorPass() {}
|
||||
static const int ID; // Pass identifcation, replacement for typeid
|
||||
BlockExtractorPass(std::vector<BasicBlock*> &B)
|
||||
: ModulePass((intptr_t)&ID), BlocksToNotExtract(B) {}
|
||||
BlockExtractorPass() : ModulePass((intptr_t)&ID) {}
|
||||
|
||||
bool runOnModule(Module &M);
|
||||
};
|
||||
|
||||
const int BlockExtractorPass::ID = 0;
|
||||
RegisterPass<BlockExtractorPass>
|
||||
XX("extract-blocks", "Extract Basic Blocks From Module (for bugpoint use)");
|
||||
}
|
||||
|
@@ -109,6 +109,9 @@ namespace {
|
||||
|
||||
bool IsTransformableFunction(const std::string& Name);
|
||||
public:
|
||||
static const int ID; // Pass identifcation, replacement for typeid
|
||||
LowerSetJmp() : ModulePass((intptr_t)&ID) {}
|
||||
|
||||
void visitCallInst(CallInst& CI);
|
||||
void visitInvokeInst(InvokeInst& II);
|
||||
void visitReturnInst(ReturnInst& RI);
|
||||
@@ -118,6 +121,7 @@ namespace {
|
||||
bool doInitialization(Module& M);
|
||||
};
|
||||
|
||||
const int LowerSetJmp::ID = 0;
|
||||
RegisterPass<LowerSetJmp> X("lowersetjmp", "Lower Set Jump");
|
||||
} // end anonymous namespace
|
||||
|
||||
|
@@ -35,6 +35,9 @@ STATISTIC(NumUnreach, "Number of noreturn calls optimized");
|
||||
|
||||
namespace {
|
||||
struct VISIBILITY_HIDDEN PruneEH : public CallGraphSCCPass {
|
||||
static const int ID; // Pass identifcation, replacement for typeid
|
||||
PruneEH() : CallGraphSCCPass((intptr_t)&ID) {}
|
||||
|
||||
/// DoesNotUnwind - This set contains all of the functions which we have
|
||||
/// determined cannot unwind.
|
||||
std::set<CallGraphNode*> DoesNotUnwind;
|
||||
@@ -49,6 +52,8 @@ namespace {
|
||||
bool SimplifyFunction(Function *F);
|
||||
void DeleteBasicBlock(BasicBlock *BB);
|
||||
};
|
||||
|
||||
const int PruneEH::ID = 0;
|
||||
RegisterPass<PruneEH> X("prune-eh", "Remove unused exception handling info");
|
||||
}
|
||||
|
||||
|
@@ -35,7 +35,9 @@ namespace {
|
||||
Function *MallocFunc; // Functions in the module we are processing
|
||||
Function *FreeFunc; // Initialized by doPassInitializationVirt
|
||||
public:
|
||||
RaiseAllocations() : MallocFunc(0), FreeFunc(0) {}
|
||||
static const int ID; // Pass identifcation, replacement for typeid
|
||||
RaiseAllocations()
|
||||
: ModulePass((intptr_t)&ID), MallocFunc(0), FreeFunc(0) {}
|
||||
|
||||
// doPassInitialization - For the raise allocations pass, this finds a
|
||||
// declaration for malloc and free if they exist.
|
||||
@@ -47,6 +49,7 @@ namespace {
|
||||
bool runOnModule(Module &M);
|
||||
};
|
||||
|
||||
const int RaiseAllocations::ID = 0;
|
||||
RegisterPass<RaiseAllocations>
|
||||
X("raiseallocs", "Raise allocations from calls to instructions");
|
||||
} // end anonymous namespace
|
||||
|
@@ -152,6 +152,9 @@ public:
|
||||
/// @brief A ModulePass for optimizing well-known function calls.
|
||||
class VISIBILITY_HIDDEN SimplifyLibCalls : public ModulePass {
|
||||
public:
|
||||
static const int ID; // Pass identifcation, replacement for typeid
|
||||
SimplifyLibCalls() : ModulePass((intptr_t)&ID) {}
|
||||
|
||||
/// We need some target data for accurate signature details that are
|
||||
/// target dependent. So we require target data in our AnalysisUsage.
|
||||
/// @brief Require TargetData from AnalysisUsage.
|
||||
@@ -373,6 +376,7 @@ private:
|
||||
TargetData *TD; ///< Cached TargetData
|
||||
};
|
||||
|
||||
const int SimplifyLibCalls::ID = 0;
|
||||
// Register the pass
|
||||
RegisterPass<SimplifyLibCalls>
|
||||
X("simplify-libcalls", "Simplify well-known library calls");
|
||||
|
@@ -27,9 +27,12 @@ namespace {
|
||||
/// @brief Pass to remove unused function declarations.
|
||||
class VISIBILITY_HIDDEN StripDeadPrototypesPass : public ModulePass {
|
||||
public:
|
||||
StripDeadPrototypesPass() { }
|
||||
static const int ID; // Pass identifcation, replacement for typeid
|
||||
StripDeadPrototypesPass() : ModulePass((intptr_t)&ID) { }
|
||||
virtual bool runOnModule(Module &M);
|
||||
};
|
||||
|
||||
const int StripDeadPrototypesPass::ID = 0;
|
||||
RegisterPass<StripDeadPrototypesPass> X("strip-dead-prototypes",
|
||||
"Strip Unused Function Prototypes");
|
||||
|
||||
|
@@ -37,7 +37,9 @@ namespace {
|
||||
class VISIBILITY_HIDDEN StripSymbols : public ModulePass {
|
||||
bool OnlyDebugInfo;
|
||||
public:
|
||||
StripSymbols(bool ODI = false) : OnlyDebugInfo(ODI) {}
|
||||
static const int ID; // Pass identifcation, replacement for typeid
|
||||
StripSymbols(bool ODI = false)
|
||||
: ModulePass((intptr_t)&ID), OnlyDebugInfo(ODI) {}
|
||||
|
||||
virtual bool runOnModule(Module &M);
|
||||
|
||||
@@ -45,6 +47,8 @@ namespace {
|
||||
AU.setPreservesAll();
|
||||
}
|
||||
};
|
||||
|
||||
const int StripSymbols::ID = 0;
|
||||
RegisterPass<StripSymbols> X("strip", "Strip all symbols from a module");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user