[LLVMdev] Question about the old C back-end

Roel Jordans r.jordans at tue.nl
Thu Oct 11 06:18:42 PDT 2012


Hello all,

When going through the internals of the old C back-end, I see that the 
CBE encapsulates arrays into a struct.  The source code has the 
following comment to explain this behaviour.

      // Arrays are wrapped in structs to allow them to have normal
      // value semantics (avoiding the array "decay").

For example, the CBE translates:
   @a = common global [10 x i32] zeroinitializer, align 16

into:
   struct { unsigned int array[10]; } a;

However, the reason for this behaviour is not completely clear to me. 
Can anyone give me further explanation of that is meant by 'array decay' 
and why it is not possible (or easy) to generate normal C-style arrays?

Cheers,
  Roel



More information about the llvm-dev mailing list