> We tried that too...but still it returns an empty map.I'm not sure what's going on then. :) I think that Vikram is planning to update CVS soon, you might try that, as there has been significant updates. I'm not sure why getNodeForValue would work for you but getScalarMap doesn't... getNodeForValue USES the scalar map! :)> We also saw that Scalar Type has been removed from the DSNode types. Why > is that?Originally, LLVM values were represented in the DSGraph as DSNodes with the Scalar field set. Thus you would have something like this: X: ( int*%X ) | | v A: [ S int*] | | v B: [ H int] IOW, X in the scalar map would point to a "scalar" node (A), which would point to the actual data the scalar points to (B). This was wasteful because scalars in LLVM can never alias each other, thus they don't need to be in the graphs. We changed the graph to now represent this situation like this: ( int*%X ) | | v B: [ H int] Now X is represented ONLY in the scalar map, and it points to whatever the scalar points to. Because the scalar nodes don't exist in the graph anymore, we dropped the flag. -Chris> > > ...... > > > DSGraph* DSG = getAnalysis<BUDataStructures>().getDSGraph( F ); > > > std::map< Value*, DSNodeHandle> scalarmap = DSG->getScalarMap(); > > > ...... > > > > > > The scalarmap is always empty. I printed the size of the map which came > > > out to be zero always. But the getNodeForValue works correctly for the > > > same DSG, which means that the scalarmap cannot be empty. But we always > > > have an empty scalarmap being returned. > > > > Try capturing a reference to the map instead of copying it: > > > > std::map<Value*, DSNodeHandle> &scalarmap = DSG->getScalarMap(); > > > > -Chris > > > > > > > On Wed, 20 Nov 2002, Chris Lattner wrote: > > > > > > > > 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/ > > > > > > > > _______________________________________________ > > > > 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/ > > > > _______________________________________________ > > 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 >-Chris -- http://llvm.cs.uiuc.edu/ http://www.nondot.org/~sabre/Projects/
Is there a way get the register on the LHS of a llvm instruction? (in case there is one) for example, given a "free %reg773", I want to find the matching "%something = malloc %", where %something is not necessarily %reg773. One way I found was to inmediately follow the use-def chain up from the free to the malloc. But instead, I want to put %reg773 in a set (possibly with many other %things), and when I find "%something = malloc" look for %something in the set. One way to do it (as far as I see) is to store the "defs" in the set. But I was thinking about storing only the "%reg" (the name, a unique identifier), but I don't see how to get it from an Instruction. I'm not sure the above explanation makes much sense. Too much caffeine, I guess. thanks in advance nicolas
Also sprach Juan Nicolas Ruiz: } Is there a way get the register on the LHS of a llvm instruction? (in } case there is one) } } for example, given a "free %reg773", I want to find the matching } "%something = malloc %", where %something is not necessarily %reg773. } One way I found was to inmediately follow the use-def chain up from } the free to the malloc. But instead, I want to put %reg773 in a set } (possibly with many other %things), and when I find } "%something = malloc" look for %something in the set. One way to do it } (as far as I see) is to store the "defs" in the set. But I was } thinking about storing only the "%reg" (the name, a unique } identifier), but I don't see how to get it from an Instruction. } You can get the name of an instruction with the "getName()" method. However, it's been pointed out that names are rather meaningless in LLVM and aren't guaranteed to be unique. Why not store a Value* instead? (Or Instruction* if you prefer) I'm not sure if this solves your problem, 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
If I understand this right, you want to find the malloc that created the object(s) being freed by a free instruction. That requires alias information, and you can do this using DS Graphs: (1) To find matching mallocs in the same function: for each Instruction* I that is a malloc: Check if I points to the same DS node as the argument of the free Obviously this is expensive if you don't already know have a set of mallocs to test. You don't want to loop over all the instructions in the procedure. (2) To find matching mallocs in other functions: This is more work. You have to match the DS Node pointed to by the free to DS nodes in other functions and look for mallocs that point to the corresponding DS node in other functions. More generally, (if you really need to do this kind of search) I think you should try to make it faster by keeping track of malloc instructions for each DS Node in some appropriate data structure. --Vikram http://www.cs.uiuc.edu/~vadve> -----Original Message----- > From: llvmdev-admin at cs.uiuc.edu > [mailto:llvmdev-admin at cs.uiuc.edu] On Behalf Of Juan Nicolas Ruiz > Sent: Wednesday, November 20, 2002 10:45 PM > To: llvmdev at cs.uiuc.edu > Subject: [LLVMdev] instruction/register identifier? > > > Is there a way get the register on the LHS of a llvm > instruction? (in case there is one) > > for example, given a "free %reg773", I want to find the > matching "%something = malloc %", where %something is not > necessarily %reg773. One way I found was to inmediately > follow the use-def chain up from the free to the malloc. But > instead, I want to put %reg773 in a set (possibly with many > other %things), and when I find "%something = malloc" look > for %something in the set. One way to do it (as far as I see) > is to store the "defs" in the set. But I was thinking about > storing only the "%reg" (the name, a unique identifier), but > I don't see how to get it from an Instruction. > > I'm not sure the above explanation makes much sense. Too much > caffeine, I guess. > > thanks in advance > nicolas > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev >