mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-19 04:32:19 +00:00
* Add data structures and code to track the call sites for each function
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4213 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8d00c8210e
commit
613692c106
@ -10,9 +10,7 @@
|
|||||||
#include "llvm/Analysis/DataStructure.h"
|
#include "llvm/Analysis/DataStructure.h"
|
||||||
#include "llvm/Analysis/DSGraph.h"
|
#include "llvm/Analysis/DSGraph.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
//#include "llvm/DerivedTypes.h"
|
|
||||||
#include "Support/Statistic.h"
|
#include "Support/Statistic.h"
|
||||||
//#include <set>
|
|
||||||
using std::map;
|
using std::map;
|
||||||
|
|
||||||
static RegisterAnalysis<BUDataStructures>
|
static RegisterAnalysis<BUDataStructures>
|
||||||
@ -32,6 +30,9 @@ using namespace DataStructureAnalysis;
|
|||||||
// our memory... here...
|
// our memory... here...
|
||||||
//
|
//
|
||||||
void BUDataStructures::releaseMemory() {
|
void BUDataStructures::releaseMemory() {
|
||||||
|
// Delete all call site information
|
||||||
|
CallSites.clear();
|
||||||
|
|
||||||
for (map<const Function*, DSGraph*>::iterator I = DSInfo.begin(),
|
for (map<const Function*, DSGraph*>::iterator I = DSInfo.begin(),
|
||||||
E = DSInfo.end(); I != E; ++I)
|
E = DSInfo.end(); I != E; ++I)
|
||||||
delete I->second;
|
delete I->second;
|
||||||
@ -151,6 +152,10 @@ DSGraph &BUDataStructures::calculateGraph(Function &F) {
|
|||||||
for (unsigned c = 0; c != Callees.size(); ++c) {
|
for (unsigned c = 0; c != Callees.size(); ++c) {
|
||||||
// Must be a function type, so this cast MUST succeed.
|
// Must be a function type, so this cast MUST succeed.
|
||||||
Function &FI = cast<Function>(*Callees[c]);
|
Function &FI = cast<Function>(*Callees[c]);
|
||||||
|
|
||||||
|
// Record that this is a call site of FI.
|
||||||
|
CallSites[&FI].push_back(CallSite(F, Call));
|
||||||
|
|
||||||
if (&FI == &F) {
|
if (&FI == &F) {
|
||||||
// Self recursion... simply link up the formal arguments with the
|
// Self recursion... simply link up the formal arguments with the
|
||||||
// actual arguments...
|
// actual arguments...
|
||||||
@ -165,6 +170,7 @@ DSGraph &BUDataStructures::calculateGraph(Function &F) {
|
|||||||
|
|
||||||
// Erase the entry in the callees vector
|
// Erase the entry in the callees vector
|
||||||
Callees.erase(Callees.begin()+c--);
|
Callees.erase(Callees.begin()+c--);
|
||||||
|
|
||||||
} else if (!FI.isExternal()) {
|
} else if (!FI.isExternal()) {
|
||||||
DEBUG(std::cerr << "\t[BU] In " << F.getName() << " inlining: "
|
DEBUG(std::cerr << "\t[BU] In " << F.getName() << " inlining: "
|
||||||
<< FI.getName() << "\n");
|
<< FI.getName() << "\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user