mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
In debug builds, make a statistic for each kind of call optimization. This
helps track down what gets triggered in the pass so its easier to identify good test cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21582 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
bc9fa589ef
commit
1ea099c5fd
@ -96,8 +96,16 @@ namespace {
|
||||
) = 0;
|
||||
|
||||
const char * getFunctionName() const { return func_name; }
|
||||
|
||||
#ifndef NDEBUG
|
||||
void activate() { ++activations; }
|
||||
#endif
|
||||
|
||||
private:
|
||||
const char* func_name;
|
||||
#ifndef NDEBUG
|
||||
Statistic<> activations;
|
||||
#endif
|
||||
};
|
||||
|
||||
/// @brief The list of optimizations deriving from CallOptimizer
|
||||
@ -106,6 +114,9 @@ namespace {
|
||||
|
||||
CallOptimizer::CallOptimizer(const char* fname)
|
||||
: func_name(fname)
|
||||
#ifndef NDEBUG
|
||||
, activations(fname,"Number of calls simplified")
|
||||
#endif
|
||||
{
|
||||
// Register this call optimizer
|
||||
optlist[func_name] = this;
|
||||
@ -149,14 +160,18 @@ bool SimplifyLibCalls::runOnModule(Module &M)
|
||||
// because they live in a runtime library somewhere and were (probably)
|
||||
// not compiled by LLVM. So, we only act on external functions that have
|
||||
// external linkage and non-empty uses.
|
||||
if (FI->isExternal() && FI->hasExternalLinkage() && !FI->use_empty())
|
||||
{
|
||||
if (!FI->isExternal() || !FI->hasExternalLinkage() || FI->use_empty())
|
||||
continue;
|
||||
|
||||
// Get the optimization class that pertains to this function
|
||||
if (CallOptimizer* CO = optlist[FI->getName().c_str()] )
|
||||
{
|
||||
CallOptimizer* CO = optlist[FI->getName().c_str()];
|
||||
if (!CO)
|
||||
continue;
|
||||
|
||||
// Make sure the called function is suitable for the optimization
|
||||
if (CO->ValidateCalledFunction(FI,TD))
|
||||
{
|
||||
if (!CO->ValidateCalledFunction(FI,TD))
|
||||
continue;
|
||||
|
||||
// Loop over each of the uses of the function
|
||||
for (Value::use_iterator UI = FI->use_begin(), UE = FI->use_end();
|
||||
UI != UE ; )
|
||||
@ -169,10 +184,9 @@ bool SimplifyLibCalls::runOnModule(Module &M)
|
||||
{
|
||||
++SimplifiedLibCalls;
|
||||
found_optimization = result = true;
|
||||
DEBUG(std::cerr << "simplify-libcall: " << CO->getFunctionName() << "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
CO->activate();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user