[llvm-commits] [llvm] r37940 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGNodes.h include/llvm/ParameterAttributes.h lib/AsmParser/Lexer.l lib/AsmParser/llvmAsmParser.y lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp lib/Target/TargetCallingConv.td lib/Target/X86/X86CallingConv.td lib/VMCore/Function.cpp lib/VMCore/Verifier.cpp utils/TableGen/CallingConvEmitter.cpp

Reid Spencer rspencer at reidspencer.com
Sat Jul 7 09:17:25 PDT 2007


Hi Duncan,

On Sat, 2007-07-07 at 12:24 +0200, Duncan Sands wrote:
> Hi Reid,
> 
> > > +    ByVal             = 1<<4,  ///< Struct passed by value
> > 
> > I would prefer this be named StructByVal, to be clear
> 
> this was changed because it should also be possible to pass arrays
> by value, not just structs.  So it is rather the comment that should
> be fixed, not the name.  That said, ByVal is a little confusing since
> eg an integer is passed by value but is not marked ByVal.  Not clear
> what a better name would be...

Okay, so now I'm really confused. :)

The Verifier is checking to make sure that the argument type to which
ByVal is applied is a pointer. It doesn't check any further so I assume
a pointer to anything is valid. So, consider the following:

1. i32*              ; i32 is passed?
2. i1024*            ; We pass a 128-byte long integer?
3. f64*              ; We pass a double?
4. {i32,i32,i32}*    ; We pass 3 i32 integers?
5. <4xi32>*          ; We pass 4 i32 integers?
6. [1024xi32>*       ; We pass 1024 i32 integers?

>From an assembly language point of view, this seems redundant with
existing capabilities as well as violating one of the tenets of the
language (can only pass first class types).  

In cases 1, 3, 4 and 5 the front end could have just done the
getelementptr and load(s) necessary. For cases 2 and 6, the implied
loads are a performance issue so it would be better to pass the pointer.
Also, in all these cases, the implied signature of the function is
different. How does this play with calling conventions?

Am I missing something here? Because if I'm not then I'm -1 on this
feature as a whole. What's the objective of this?

Reid.

> 
> Ciao,
> 
> Duncan.




More information about the llvm-commits mailing list