Ganesh, I modified DataStructure.cpp so that global nodes are no longer removed from any graphs. Only that file has changed. Chris, if you get a chance to do this, it would be nice if you could take a quick look at the change I made and make sure that's all that's needed. Thanks, --Vikram http://www.cs.uiuc.edu/~vadve> From: Chris Lattner <sabre at nondot.org> > Subject: Re: [LLVMdev] globals in DS graph > Sender: llvmdev-admin at cs.uiuc.edu > Date: Mon, 25 Nov 2002 01:34:14 -0600 (CST) > > > 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 > > -- > http://llvm.cs.uiuc.edu/ > http://www.nondot.org/~sabre/Projects/ > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev >
On Mon, 25 Nov 2002, Vikram Adve wrote:> I modified DataStructure.cpp so that global nodes are no longer > removed from any graphs. Only that file has changed. > > Chris, if you get a chance to do this, it would be nice if you could > take a quick look at the change I made and make sure that's all that's > needed.That looks right to me, thanks! -Chris> > From: Chris Lattner <sabre at nondot.org> > > Subject: Re: [LLVMdev] globals in DS graph > > Sender: llvmdev-admin at cs.uiuc.edu > > Date: Mon, 25 Nov 2002 01:34:14 -0600 (CST) > > > > > 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 > > > > -- > > http://llvm.cs.uiuc.edu/ > > http://www.nondot.org/~sabre/Projects/ > > > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev > > > >-Chris -- http://llvm.cs.uiuc.edu/ http://www.nondot.org/~sabre/Projects/
Prof. Vikram, I updated the DataStructure.cpp and recompiled the llvm. But still I have the same scenario. I don't get the same DSnode for global. I tried several methods; but none of them were successful. I used the getNodeForValue and again I found that the global value had different nodes in different functions. However, the getGlobals worked well for function call. Thanks, Ganesh On Mon, 25 Nov 2002, Vikram Adve wrote:> Ganesh, > > I modified DataStructure.cpp so that global nodes are no longer > removed from any graphs. Only that file has changed. > > Chris, if you get a chance to do this, it would be nice if you could > take a quick look at the change I made and make sure that's all that's > needed. > > Thanks, > > --Vikram > http://www.cs.uiuc.edu/~vadve > > > > From: Chris Lattner <sabre at nondot.org> > > Subject: Re: [LLVMdev] globals in DS graph > > Sender: llvmdev-admin at cs.uiuc.edu > > Date: Mon, 25 Nov 2002 01:34:14 -0600 (CST) > > > > > 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 > > > > -- > > http://llvm.cs.uiuc.edu/ > > http://www.nondot.org/~sabre/Projects/ > > > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev >Graduate Research Assistant Computer Science University of Illinois, Champaign-Urbana
Ganesh, Every graph has a separate copy of the node for a global. There is no sharing of nodes between graphs. For any particular global object (a GlobalValue*), you can find the node for that global in each graph from the ScalarMap for that graph. Eventually, irrelevant^(*) globals within each function's graph will be deleted but other globals will stay the same as they are now. When that happens, we will need to fully implement the globals graph for our graph construction algorithm, but even then many clients (including yours) may never really need to know about the globals graph. (*) A global is irrelevant in a function if it is not reachable from and cannot reach any node that is accessible within that function. Such a global cannot be used to reference or modify any accessible node within that function. --Vikram http://www.cs.uiuc.edu/~vadve> From: Ganesh Bikshandi <bikshand at students.uiuc.edu> > Date: Mon, 25 Nov 2002 17:46:33 -0600 (CST) > Subject: Re: [LLVMdev] globals in DS graph > > Prof. Vikram, > > I updated the DataStructure.cpp and recompiled the llvm. But still I have > the same scenario. I don't get the same DSnode for global. I tried several > methods; but none of them were successful. I used the getNodeForValue and > again I found that the global value had different nodes in different > functions. However, the getGlobals worked well for function call. > > Thanks, > Ganesh > On Mon, 25 Nov 2002, Vikram Adve wrote: > > > Ganesh, > > > > I modified DataStructure.cpp so that global nodes are no longer > > removed from any graphs. Only that file has changed. > > > > Chris, if you get a chance to do this, it would be nice if you could > > take a quick look at the change I made and make sure that's all that's > > needed. > > > > Thanks, > > > > --Vikram > > http://www.cs.uiuc.edu/~vadve