[LLVMdev] on type annotations of LLVM IR

David Chisnall David.Chisnall at cl.cam.ac.uk
Mon Oct 27 06:14:53 PDT 2014

On 27 Oct 2014, at 12:46, Rekha R <rekharamapai at nitc.ac.in> wrote:

> Why wasn't the C style of explicit declaration of variables (or values in LLVM context) followed by their uses model not adopted here?

For the simple reason that there are no variables in LLVM IR.  The SSA form means that every value is declared and initialised exactly once.  Some values, such as constant integers, are created (in the text serialisation) inline in their use so there is no point where they are declared.  

> or may be even annotate the value (result of the Instruction) with type rather than annotating each operands on the Instruction?
> Just felt that by annotating each operand with types may make the Instruction 'complex' to understand. May be I am wrong.

You will find it much easier to read when you are debugging.  The IR is not intended to be read or written by humans, the text serialisation is there as a debugging aid when something has gone wrong.  It is *very* useful to be able to look at a single instruction and see all of the types, without having to chase through a load of other parts of the code to find where things were declared.  


More information about the llvm-dev mailing list