mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
Switch from using CallInst's to represent call sites to using the LLVM
CallSite class. Now we can represent function calls by invoke instructions too! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8629 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -7,11 +7,9 @@
|
||||
#ifndef LLVM_ANALYSIS_DSSUPPORT_H
|
||||
#define LLVM_ANALYSIS_DSSUPPORT_H
|
||||
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include "Support/hash_set"
|
||||
#include "llvm/Support/CallSite.h"
|
||||
|
||||
class Function;
|
||||
class CallInst;
|
||||
@@ -127,7 +125,7 @@ namespace std {
|
||||
/// the DSNode handles for the function arguments.
|
||||
///
|
||||
class DSCallSite {
|
||||
CallInst *Inst; // Actual call site
|
||||
CallSite Site; // Actual call site
|
||||
Function *CalleeF; // The function called (direct call)
|
||||
DSNodeHandle CalleeN; // The function node called (indirect call)
|
||||
DSNodeHandle RetVal; // Returned value
|
||||
@@ -160,21 +158,21 @@ public:
|
||||
/// Constructor. Note - This ctor destroys the argument vector passed in. On
|
||||
/// exit, the argument vector is empty.
|
||||
///
|
||||
DSCallSite(CallInst &inst, const DSNodeHandle &rv, DSNode *Callee,
|
||||
DSCallSite(CallSite CS, const DSNodeHandle &rv, DSNode *Callee,
|
||||
std::vector<DSNodeHandle> &Args)
|
||||
: Inst(&inst), CalleeF(0), CalleeN(Callee), RetVal(rv) {
|
||||
: Site(CS), CalleeF(0), CalleeN(Callee), RetVal(rv) {
|
||||
assert(Callee && "Null callee node specified for call site!");
|
||||
Args.swap(CallArgs);
|
||||
}
|
||||
DSCallSite(CallInst &inst, const DSNodeHandle &rv, Function *Callee,
|
||||
DSCallSite(CallSite CS, const DSNodeHandle &rv, Function *Callee,
|
||||
std::vector<DSNodeHandle> &Args)
|
||||
: Inst(&inst), CalleeF(Callee), RetVal(rv) {
|
||||
: Site(CS), CalleeF(Callee), RetVal(rv) {
|
||||
assert(Callee && "Null callee function specified for call site!");
|
||||
Args.swap(CallArgs);
|
||||
}
|
||||
|
||||
DSCallSite(const DSCallSite &DSCS) // Simple copy ctor
|
||||
: Inst(DSCS.Inst), CalleeF(DSCS.CalleeF), CalleeN(DSCS.CalleeN),
|
||||
: Site(DSCS.Site), CalleeF(DSCS.CalleeF), CalleeN(DSCS.CalleeN),
|
||||
RetVal(DSCS.RetVal), CallArgs(DSCS.CallArgs) {}
|
||||
|
||||
/// Mapping copy constructor - This constructor takes a preexisting call site
|
||||
@@ -183,7 +181,7 @@ public:
|
||||
///
|
||||
template<typename MapTy>
|
||||
DSCallSite(const DSCallSite &FromCall, const MapTy &NodeMap) {
|
||||
Inst = FromCall.Inst;
|
||||
Site = FromCall.Site;
|
||||
InitNH(RetVal, FromCall.RetVal, NodeMap);
|
||||
InitNH(CalleeN, FromCall.CalleeN, NodeMap);
|
||||
CalleeF = FromCall.CalleeF;
|
||||
@@ -194,7 +192,7 @@ public:
|
||||
}
|
||||
|
||||
const DSCallSite &operator=(const DSCallSite &RHS) {
|
||||
Inst = RHS.Inst;
|
||||
Site = RHS.Site;
|
||||
CalleeF = RHS.CalleeF;
|
||||
CalleeN = RHS.CalleeN;
|
||||
RetVal = RHS.RetVal;
|
||||
@@ -212,7 +210,7 @@ public:
|
||||
|
||||
// Accessor functions...
|
||||
Function &getCaller() const;
|
||||
CallInst &getCallInst() const { return *Inst; }
|
||||
CallSite getCallSite() const { return Site; }
|
||||
DSNodeHandle &getRetVal() { return RetVal; }
|
||||
const DSNodeHandle &getRetVal() const { return RetVal; }
|
||||
|
||||
@@ -236,7 +234,7 @@ public:
|
||||
|
||||
void swap(DSCallSite &CS) {
|
||||
if (this != &CS) {
|
||||
std::swap(Inst, CS.Inst);
|
||||
std::swap(Site, CS.Site);
|
||||
std::swap(RetVal, CS.RetVal);
|
||||
std::swap(CalleeN, CS.CalleeN);
|
||||
std::swap(CalleeF, CS.CalleeF);
|
||||
|
@@ -11,10 +11,9 @@
|
||||
#include "Support/hash_set"
|
||||
|
||||
class Type;
|
||||
class CallInst;
|
||||
class Instruction;
|
||||
class DSGraph;
|
||||
class DSNode;
|
||||
class DSCallSite;
|
||||
|
||||
// FIXME: move this stuff to a private header
|
||||
namespace DataStructureAnalysis {
|
||||
@@ -75,7 +74,7 @@ class BUDataStructures : public Pass {
|
||||
// DSInfo, one graph for each function
|
||||
hash_map<Function*, DSGraph*> DSInfo;
|
||||
DSGraph *GlobalsGraph;
|
||||
hash_multimap<CallInst*, Function*> ActualCallees;
|
||||
hash_multimap<Instruction*, Function*> ActualCallees;
|
||||
public:
|
||||
~BUDataStructures() { releaseMemory(); }
|
||||
|
||||
@@ -106,7 +105,7 @@ public:
|
||||
AU.addRequired<LocalDataStructures>();
|
||||
}
|
||||
|
||||
typedef hash_multimap<CallInst*, Function*> ActualCalleesTy;
|
||||
typedef hash_multimap<Instruction*, Function*> ActualCalleesTy;
|
||||
const ActualCalleesTy &getActualCallees() const {
|
||||
return ActualCallees;
|
||||
}
|
||||
|
@@ -7,11 +7,9 @@
|
||||
#ifndef LLVM_ANALYSIS_DSSUPPORT_H
|
||||
#define LLVM_ANALYSIS_DSSUPPORT_H
|
||||
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include "Support/hash_set"
|
||||
#include "llvm/Support/CallSite.h"
|
||||
|
||||
class Function;
|
||||
class CallInst;
|
||||
@@ -127,7 +125,7 @@ namespace std {
|
||||
/// the DSNode handles for the function arguments.
|
||||
///
|
||||
class DSCallSite {
|
||||
CallInst *Inst; // Actual call site
|
||||
CallSite Site; // Actual call site
|
||||
Function *CalleeF; // The function called (direct call)
|
||||
DSNodeHandle CalleeN; // The function node called (indirect call)
|
||||
DSNodeHandle RetVal; // Returned value
|
||||
@@ -160,21 +158,21 @@ public:
|
||||
/// Constructor. Note - This ctor destroys the argument vector passed in. On
|
||||
/// exit, the argument vector is empty.
|
||||
///
|
||||
DSCallSite(CallInst &inst, const DSNodeHandle &rv, DSNode *Callee,
|
||||
DSCallSite(CallSite CS, const DSNodeHandle &rv, DSNode *Callee,
|
||||
std::vector<DSNodeHandle> &Args)
|
||||
: Inst(&inst), CalleeF(0), CalleeN(Callee), RetVal(rv) {
|
||||
: Site(CS), CalleeF(0), CalleeN(Callee), RetVal(rv) {
|
||||
assert(Callee && "Null callee node specified for call site!");
|
||||
Args.swap(CallArgs);
|
||||
}
|
||||
DSCallSite(CallInst &inst, const DSNodeHandle &rv, Function *Callee,
|
||||
DSCallSite(CallSite CS, const DSNodeHandle &rv, Function *Callee,
|
||||
std::vector<DSNodeHandle> &Args)
|
||||
: Inst(&inst), CalleeF(Callee), RetVal(rv) {
|
||||
: Site(CS), CalleeF(Callee), RetVal(rv) {
|
||||
assert(Callee && "Null callee function specified for call site!");
|
||||
Args.swap(CallArgs);
|
||||
}
|
||||
|
||||
DSCallSite(const DSCallSite &DSCS) // Simple copy ctor
|
||||
: Inst(DSCS.Inst), CalleeF(DSCS.CalleeF), CalleeN(DSCS.CalleeN),
|
||||
: Site(DSCS.Site), CalleeF(DSCS.CalleeF), CalleeN(DSCS.CalleeN),
|
||||
RetVal(DSCS.RetVal), CallArgs(DSCS.CallArgs) {}
|
||||
|
||||
/// Mapping copy constructor - This constructor takes a preexisting call site
|
||||
@@ -183,7 +181,7 @@ public:
|
||||
///
|
||||
template<typename MapTy>
|
||||
DSCallSite(const DSCallSite &FromCall, const MapTy &NodeMap) {
|
||||
Inst = FromCall.Inst;
|
||||
Site = FromCall.Site;
|
||||
InitNH(RetVal, FromCall.RetVal, NodeMap);
|
||||
InitNH(CalleeN, FromCall.CalleeN, NodeMap);
|
||||
CalleeF = FromCall.CalleeF;
|
||||
@@ -194,7 +192,7 @@ public:
|
||||
}
|
||||
|
||||
const DSCallSite &operator=(const DSCallSite &RHS) {
|
||||
Inst = RHS.Inst;
|
||||
Site = RHS.Site;
|
||||
CalleeF = RHS.CalleeF;
|
||||
CalleeN = RHS.CalleeN;
|
||||
RetVal = RHS.RetVal;
|
||||
@@ -212,7 +210,7 @@ public:
|
||||
|
||||
// Accessor functions...
|
||||
Function &getCaller() const;
|
||||
CallInst &getCallInst() const { return *Inst; }
|
||||
CallSite getCallSite() const { return Site; }
|
||||
DSNodeHandle &getRetVal() { return RetVal; }
|
||||
const DSNodeHandle &getRetVal() const { return RetVal; }
|
||||
|
||||
@@ -236,7 +234,7 @@ public:
|
||||
|
||||
void swap(DSCallSite &CS) {
|
||||
if (this != &CS) {
|
||||
std::swap(Inst, CS.Inst);
|
||||
std::swap(Site, CS.Site);
|
||||
std::swap(RetVal, CS.RetVal);
|
||||
std::swap(CalleeN, CS.CalleeN);
|
||||
std::swap(CalleeF, CS.CalleeF);
|
||||
|
@@ -11,10 +11,9 @@
|
||||
#include "Support/hash_set"
|
||||
|
||||
class Type;
|
||||
class CallInst;
|
||||
class Instruction;
|
||||
class DSGraph;
|
||||
class DSNode;
|
||||
class DSCallSite;
|
||||
|
||||
// FIXME: move this stuff to a private header
|
||||
namespace DataStructureAnalysis {
|
||||
@@ -75,7 +74,7 @@ class BUDataStructures : public Pass {
|
||||
// DSInfo, one graph for each function
|
||||
hash_map<Function*, DSGraph*> DSInfo;
|
||||
DSGraph *GlobalsGraph;
|
||||
hash_multimap<CallInst*, Function*> ActualCallees;
|
||||
hash_multimap<Instruction*, Function*> ActualCallees;
|
||||
public:
|
||||
~BUDataStructures() { releaseMemory(); }
|
||||
|
||||
@@ -106,7 +105,7 @@ public:
|
||||
AU.addRequired<LocalDataStructures>();
|
||||
}
|
||||
|
||||
typedef hash_multimap<CallInst*, Function*> ActualCalleesTy;
|
||||
typedef hash_multimap<Instruction*, Function*> ActualCalleesTy;
|
||||
const ActualCalleesTy &getActualCallees() const {
|
||||
return ActualCallees;
|
||||
}
|
||||
|
@@ -45,7 +45,10 @@
|
||||
|
||||
class Module;
|
||||
class Function;
|
||||
class CallSite;
|
||||
class Instruction;
|
||||
class CallInst;
|
||||
class InvokeInst;
|
||||
class DSNode;
|
||||
class DSGraph;
|
||||
class DSNodeHandle;
|
||||
@@ -117,15 +120,15 @@ class FunctionModRefInfo {
|
||||
IPModRef& IPModRefObj; // The IPModRef Object owning this
|
||||
DSGraph* funcTDGraph; // Top-down DS graph for function
|
||||
ModRefInfo funcModRefInfo; // ModRefInfo for the function body
|
||||
std::map<const CallInst*, ModRefInfo*>
|
||||
std::map<const Instruction*, ModRefInfo*>
|
||||
callSiteModRefInfo; // ModRefInfo for each callsite
|
||||
std::map<const DSNode*, unsigned> NodeIds;
|
||||
|
||||
friend class IPModRef;
|
||||
|
||||
void computeModRef (const Function &func);
|
||||
void computeModRef (const CallInst& callInst);
|
||||
DSGraph *ResolveCallSiteModRefInfo(CallInst &CI,
|
||||
void computeModRef (CallSite call);
|
||||
DSGraph *ResolveCallSiteModRefInfo(CallSite CS,
|
||||
hash_map<const DSNode*, DSNodeHandle> &NodeMap);
|
||||
|
||||
public:
|
||||
@@ -145,9 +148,14 @@ public:
|
||||
return &funcModRefInfo;
|
||||
}
|
||||
const ModRefInfo* getModRefInfo (const CallInst& callInst) const {
|
||||
std::map<const CallInst*, ModRefInfo*>::const_iterator I =
|
||||
callSiteModRefInfo.find(&callInst);
|
||||
return (I == callSiteModRefInfo.end())? NULL : I->second;
|
||||
std::map<const Instruction*, ModRefInfo*>::const_iterator I =
|
||||
callSiteModRefInfo.find((Instruction*)&callInst);
|
||||
return (I == callSiteModRefInfo.end()) ? NULL : I->second;
|
||||
}
|
||||
const ModRefInfo* getModRefInfo (const InvokeInst& II) const {
|
||||
std::map<const Instruction*, ModRefInfo*>::const_iterator I =
|
||||
callSiteModRefInfo.find((Instruction*)&II);
|
||||
return (I == callSiteModRefInfo.end()) ? NULL : I->second;
|
||||
}
|
||||
|
||||
// Get the nodeIds used to index all Mod/Ref information for current function
|
||||
|
Reference in New Issue
Block a user