Ejemplo n.º 1
0
void benchAnalyzingVertices(CallGraph& graph) {
    Infos infos;
    Analyzer analyzer(graph, infos);

    Timer timer;

    FunctionIterator fit, fend;
    for (boost::tie(fit, fend) = graph.functions(); fit != fend; ++fit) {
        analyzer.computeFunctionTemperature(*fit);
    }

    analyzeVertices += timer.elapsed();
}
Ejemplo n.º 2
0
void benchForeachVertices(const CallGraph& graph) {
    double sum = 0;

    Timer timer;

    FunctionIterator first, last;
    for (boost::tie(first, last) = graph.functions(); first != last; ++first) {
        sum += graph[*first].temperature;
    }

    foreachVertices += timer.elapsed();

    fakeSum += sum;
}
int main(int argc, const char* argv[]) {
    if (argc < 2) {
        cout << "Not enough arguments. Provide at least the dot file to read" << endl;

        return 1;
    }

    Parameters::init();

    Infos infos;
    GraphReader reader(infos);
    CallGraph* graph = reader.read(argv[1]);

    ofstream stream;
    stream.open("main.cpp");

    stream << "//Auto generated by inlining analyzer" << endl;
    stream << "#include <iostream>" << endl << endl;

    stream << "using std::cout;" << endl;
    stream << "using std::endl;" << endl << endl;

    string mainFunction = "";

    //Print the declarations
    FunctionIterator first, last;
    for (boost::tie(first, last) = graph->functions(); first != last; ++first) {
        string name = (*graph)[*first].name;

        transform(name);

        if (filter(name)) {
            continue;
        }

        if ((*graph)[*first].calls == 0) {
            mainFunction = name;
        }

        //Declaration
        stream << "void FFF" << name << "() __attribute__ ((noinline));" << endl;
    }

    //Print the definitions
    for (boost::tie(first, last) = graph->functions(); first != last; ++first) {
        string name = (*graph)[*first].name;

        transform(name);

        if (filter(name)) {
            continue;
        }

        //Definition
        stream << "void FFF" << name << "() {" << endl;
        stream << "\tcout << \"I'm in " << name << "\" << endl;" << endl;

        OutCallSiteIterator it, end;
        for (boost::tie(it, end) = boost::out_edges(*first, *graph->getGraph()); it != end; ++it) {
            string called = (*graph)[boost::target(*it, *graph->getGraph())].name;

            transform(called);

            if (filter(called)) {
                continue;
            }

            stream << "\tFFF" << called << "();" << endl;
        }

        stream << "}" << endl << endl;
    }

    //Write main function
    stream << "int main(){" << endl;
    stream << "\tcout << \"I'm in main()\" << endl;" << endl;
    stream << "\tFFF" << mainFunction << "();" << endl;
    stream << "\treturn 0;" << endl;
    stream << "}" << endl;

    stream.close();

    delete graph;

    return 0;
}