Currently, yes. What's actually happening is that the call gets moved to
the "globals graph". Essentially, this is due to the fact that the
function call cannot modify the local memory graph of the current
function. In cases where the target pointer is null like this, you can
safely assume that the called function doesn't modify the current graph.
-Chris
It is valid that a function returns without using an Instruction::Ret
as the last instruction? If so, can we assume that a BasicBlock with
no successors is an exit BB?
It is valid that a function returns without using an Instruction::Ret
as the last instruction?
No: http://llvm.cs.uiuc.edu/docs/LangRef.html#terminators
All basic blocks must have a terminator.
If so, can we assume that a BasicBlock with
no successors is an exit BB?
Yes, but you don't want to do this. Just do:
if (isa<ReturnInst>(BB->getTerminator()))
and be done with it, that's much more explicit.
-Chris
How do I recognize that the callee function for a Instruction::Call is
external? I have:
CallInst *CI = cast<CallInst>(Inst);
Function *G = CI->getCalledFunction();
nicolas
G->isExternal(), sorry.
How do I recognize that the callee function for a Instruction::Call is
external? I have:
CallInst *CI = cast<CallInst>(Inst);
Function *G = CI->getCalledFunction();
nicolas
Juan Nicolas Ruiz | Dept. of Computer Science
I have some questions regarding how globals are represented in DS graph.
Specifically, I wrote the following simple program:
List *g;
void alloc_func(){
g = ( List* ) malloc( sizeof( List ) );
}
void free_func(){
free( g );
}
int main(){
alloc_func();
free_func();
}
I noticed that the DSnode for g in alloc_func is different from that of
free_func and NEITHER of them had GlobalNode bit set in their types. Only
the malloc bit and the incomplete bit have been set. I am completely
clueless how to figure out if it is a global node or not. I used
getGlobals and found that the returned map had size 0.
How can I get the "common" global node of g?
I've been trying to merge DSGraphs from different Functions, but i'm
not going anywhere. For a Function F and DSGraph G, I tried this
(assumming no SCC in the callgraph):
vector<DSCallSite> CSV = G->getAuxFunctionCalls();
for (vector<DSCallSite>::iterator I = CSV.begin(), E = CSV.end();
I != E; I++) {
Value *V = I->getCallInst().getOperand(0);
Function &SF = cast<Function>(*V);
if (!SF.isExternal()) {
DSGraph *SFG = new DSGraph(SF, GG);
G->mergeInGraph(*I, *SFG, 0);
}
}
but the resulting graph has no new merged DSNodes, even though in my
test case there is a DSNode pointed by the CallInst in F and another
DSNode in G that is returned to F.
Any ideas on what I'm doing wrong?
nicolas
Specifically, I wrote the following simple program:
List *g;
void alloc_func(){
g = ( List* ) malloc( sizeof( List ) );
}
void free_func(){
free( g );
}
I don't have an LLVM tree available to me right now (as
tank/llvm.cs.uiuc.edu) is down, so take this with a grain of salt...
I noticed that the DSnode for g in alloc_func is different from that of
free_func and NEITHER of them had GlobalNode bit set in their types. Only
the malloc bit and the incomplete bit have been set. I am completely
clueless how to figure out if it is a global node or not. I used
getGlobals and found that the returned map had size 0.
There may be a few different things going on here. First of all, the
"globals" graph is only partially implemented currently. Right now, nodes
eligable to be moved to the globals graph are properly removed from the
individual function graphs, but they are never reinserted into the globals
graph. This can cause some funny disappearances that don't make a lot of
sense, and...
How can I get the "common" global node of g?
... the common node in this case never gets unified. This is one of the
top priorities for me when I get back to Illinois (after thanksgiving
break), but it is unlikely to make much progress in the mean time. If you
would like to disable this behavior, look in the DSGraph::removeDeadNodes
(or similar) in DataStructure.cpp. In it you will see the code that marks
nodes as being "alive" in the current graph. All you have to do is add
code to mark all globals as alive, and they will be propogated up to main.
Alternatively, take a look at the CVS revisions a few checkins back to see
when the globals graph stuff was added... and revert it.
I hope this helps some 
-Chris
I've been trying to merge DSGraphs from different Functions, but i'm
not going anywhere. For a Function F and DSGraph G, I tried this
(assumming no SCC in the callgraph):
vector<DSCallSite> CSV = G->getAuxFunctionCalls();
Are you sure this is returning any call site entries? Depending on what
_type_ of graph G is, it may be empty. If G is a local graph, it's empty.
If G is a BU graph, CSV will only contain "unresolvable" call sites. You
probably want just the getFunctionCalls() list, which is the set of
function calls originally found by the Local's pass.
If that doesn't help, you'll have to give me some more details about what
is not happening: is the mergeInGraph function even being called?
-Chris
for (vector<DSCallSite>::iterator I = CSV.begin(), E = CSV.end();
I != E; I++) {
Value *V = I->getCallInst().getOperand(0);
Function &SF = cast<Function>(*V);
if (!SF.isExternal()) {
DSGraph *SFG = new DSGraph(SF, GG);
G->mergeInGraph(*I, *SFG, 0);
}
}
but the resulting graph has no new merged DSNodes, even though in my
test case there is a DSNode pointed by the CallInst in F and another
DSNode in G that is returned to F.
Any ideas on what I'm doing wrong?
nicolas
_______________________________________________
LLVM Developers mailing list
LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev
-Chris