Thanks Bill. One more question, when I use the DSNode iterator to traverse a node's children. The return value of I.getNode() can only be 'const DSNode *', I cannot use 'DSNode *' type. So as a result, I always get error message like this: MemLeakage.cpp:159: invalid conversion from `const DSNode*' to `DSNode*' MemLeakage.cpp:159: initializing argument 1 of `void <unnamed>::GlobalMemLeakage::KillSetInsert(DSNode*, BBsets&)' How to use a 'Node *' type iterator? Or is there any other way to traverse the DSGraph? thanks, Jerry On Sat, 16 Nov 2002, Bill? Wendling wrote:> Also sprach Xiaodong Li: > } > } When I tried to compile the program, I got this error: > } > } ../../../include/llvm/Analysis/DSGraph.h: In member function `virtual bool > } <unnamed>::GlobalMemLeakage::run(Module&)': > } ../../../include/llvm/Analysis/DSGraph.h:38: `void > } DSGraph::operator=(const > } DSGraph&)' is private > } MemLeakage.cpp:87: within this context > } gmake: *** [Debug/MemLeakage.o] Error 1 > } > } I don't understand what this means. Basically what I did is I defined: > } map<Function *, DSGraph> funsetmap; > } and I was trying to assign the DSGraph for each function to the map. > } funsetmap[&F] = dsg; > } Could you tell me what's wrong how to fix this? > } > You're invoking the copy constructor in this code snippet: > > funsetmap[&F] = dsg; > > That is, the copy constructor for dsg (which I take to be a DSGraph > object). Ways around this: > > - Store a pointer to DSGraph instead of the DSGraph object. So > something like this: > > map<Function *, DSGraph *> funsetmap; > > // code > > funsetmap[&F] = &dsg; > > You have to be careful not to store local variables and pass them > back from a function, of course. > > - Create a wrapper class for DSGraph and have its copy constructor > clone the DSGraph object for you. This way is a bit more > complicated and might not really be necessary for what you need to > do though... > > -- > || Bill Wendling "A computer without a Microsoft operating > || wendling at isanbard.org system is like a dog without bricks tied > || to its head." -- Anonymous >
On Sat, 16 Nov 2002, Xiaodong Li wrote:> be 'const DSNode *', I cannot use 'DSNode *' type. So as a result, I > always get error message like this: > How to use a 'Node *' type iterator? Or is there any other way to traverse > the DSGraph?I will have to add a new version of the iterator. I'll do this sometime early next week. In the meantime, just cast stuff like crazy. :) -Chris> On Sat, 16 Nov 2002, Bill? Wendling wrote: > > > Also sprach Xiaodong Li: > > } > > } When I tried to compile the program, I got this error: > > } > > } ../../../include/llvm/Analysis/DSGraph.h: In member function `virtual bool > > } <unnamed>::GlobalMemLeakage::run(Module&)': > > } ../../../include/llvm/Analysis/DSGraph.h:38: `void > > } DSGraph::operator=(const > > } DSGraph&)' is private > > } MemLeakage.cpp:87: within this context > > } gmake: *** [Debug/MemLeakage.o] Error 1 > > } > > } I don't understand what this means. Basically what I did is I defined: > > } map<Function *, DSGraph> funsetmap; > > } and I was trying to assign the DSGraph for each function to the map. > > } funsetmap[&F] = dsg; > > } Could you tell me what's wrong how to fix this? > > } > > You're invoking the copy constructor in this code snippet: > > > > funsetmap[&F] = dsg; > > > > That is, the copy constructor for dsg (which I take to be a DSGraph > > object). Ways around this: > > > > - Store a pointer to DSGraph instead of the DSGraph object. So > > something like this: > > > > map<Function *, DSGraph *> funsetmap; > > > > // code > > > > funsetmap[&F] = &dsg; > > > > You have to be careful not to store local variables and pass them > > back from a function, of course. > > > > - Create a wrapper class for DSGraph and have its copy constructor > > clone the DSGraph object for you. This way is a bit more > > complicated and might not really be necessary for what you need to > > do though... > > > > -- > > || Bill Wendling "A computer without a Microsoft operating > > || wendling at isanbard.org system is like a dog without bricks tied > > || to its head." -- Anonymous > > > > _______________________________________________ > 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/
Also sprach Xiaodong Li: } Thanks Bill. One more question, when I use the DSNode iterator to } traverse a node's children. The return value of I.getNode() can only } be 'const DSNode *', I cannot use 'DSNode *' type. So as a result, I } always get error message like this: } } MemLeakage.cpp:159: invalid conversion from `const DSNode*' to `DSNode*' } MemLeakage.cpp:159: initializing argument 1 of `void } <unnamed>::GlobalMemLeakage::KillSetInsert(DSNode*, BBsets&)' } } How to use a 'Node *' type iterator? Or is there any other way to traverse } the DSGraph? } I don't know too much about the DSGraph module, so I didn't respond to that part of your question :-). However, a few things which will help. If you don't need to modify the DSNode *, then use a const_iterator instead and pass everything to functions which take const DSNode *. If you do need to modify it, then you may have to rely upon a const_cast<>() to remove the const from the object. So, you'll have code which looks like this I think: for (DSGraph::iterator B = dsg.begin(), E = dsg.end(); B != E; ++B) { DSGraph *D = const_cast<DSGraph *>(*B); // code... KillSetInsert(D); // more code... } that may work... -- || Bill Wendling "A computer without a Microsoft operating || wendling at isanbard.org system is like a dog without bricks tied || to its head." -- Anonymous
On Sat, 16 Nov 2002, Bill? Wendling wrote:> Also sprach Xiaodong Li: > } How to use a 'Node *' type iterator? Or is there any other way to traverse > } the DSGraph? > I don't know too much about the DSGraph module, so I didn't respond to > that part of your question :-). > > However, a few things which will help. If you don't need to modify the > DSNode *, then use a const_iterator instead and pass everything to > functions which take const DSNode *.Bill has a good point here. You probably don't need to modify the DSGraph for your project, so using const DSNode's directly is the right way to go... -Chris -- http://llvm.cs.uiuc.edu/ http://www.nondot.org/~sabre/Projects/
I tried to used the getScalarMap function of the DSGraph to get the nodes that the scalars point to in a function. But the getScalarMap returns a null map always. Is there any problem in the getScalarMap function or is there any "protocol" to be followed while using the function? Thanks, Ganesh
> I tried to used the getScalarMap function of the DSGraph to get the nodes > that the scalars point to in a function. But the getScalarMap returns a > null map always. Is there any problem in the getScalarMap function or is > there any "protocol" to be followed while using the function?DSGraph::getScalarMap returns a reference to the map, so this cannot be null. Do you mean that all of the "entries" in the map are null? If so, remember that DSGraphs are built in the context of some function (as indicated by hasFunction/getFunction), so only scalars in that context will be in the map... -Chris -- http://llvm.cs.uiuc.edu/ http://www.nondot.org/~sabre/Projects/