[LLVMdev] newbie question - selecting the write kind of pass

Sameer D. Sahasrabuddhe sameerds at it.iitb.ac.in
Sat Apr 2 23:08:06 PST 2005

On Sat, Apr 02, 2005 at 09:44:40PM -0600, Chris Lattner wrote:

> Ah, ok.  Well in this case, the function describing the mapping from a 
> Value* to the instruction that defines it is the identity function.  Given 
> a Value*, you can do something like this:
> Value *V = ...
> if (Instruction *I = dyn_cast<Instruction>(V)) {
>    ... V is the result of the instruction I ...
> } else {
>    ... V is some other sort of value, such as a constant or a formal
>    argument ...
> }

Thanks for that! A closer inspection of the Programmer's Manual
revealted this:

  One important aspect of LLVM is that there is no distinction between
  an SSA variable and the operation that produces it. Because of this,
  any reference to the value produced by an instruction (or the value
  available as an incoming argument, for example) is represented as a
  direct pointer to the instance of the class that represents this
  value. Although this may take some getting used to, it simplifies
  the representation and makes it easier to manipulate.

This is kinda tucked away in a corner, but should in fact be the first
thing to be said about the Value class!

> Ah whoops, right, I uh did an incredibly poor job answering your question 
> :)

Ah ok ... I assumed a standard policy of "all stupid questions will be
answered in kind" ;)

> http://llvm.cs.uiuc.edu/docs/WritingAnLLVMPass.html#releaseMemory
> That is the place you should "flush" the contents of the analysis.


Unsuppressable rave: After months spent in MachSUIF prison, LLVM is
truly liberating ... everything falls together perfectly ... if you
think something should be present in a certain way, you can bet that
it already is! :)

Research Scholar, KReSIT, IIT Bombay

More information about the llvm-dev mailing list