[cfe-dev] Struct parameters being converted to other types

Jaymie Strecker jstrecker at kosada.com
Tue Jan 15 07:39:44 PST 2013


(I previously asked this question on the llvm-dev mailing list. Someone suggested that I ask on cfe-dev instead.) 

In a project I'm working on, functions are being read in from LLVM bitcode, and then LLVM is being used to generate code that calls those functions. 

When a function with a struct parameter or return type is compiled with `clang -O0 -emit-llvm`, the resulting bitcode varies greatly depending on the type of struct. 

For example, Clang may lower a struct parameter into...

	- a "byval" pointer (for a struct with several different members)
	- a vector (for a struct with a few float members)
	- two doubles (for a struct with two double members)
	- an i64 (for a struct with two i32 members)

... and possibly more variations. 

When calling a function that takes a struct argument, I'm having to convert the argument value (the original struct type) to match the parameter type (which could be any of the above variations). 

Is there a way to avoid generating all these variations? For example, is there a Clang argument that would cause all structs to be passed as "byval" pointers? 

---
Jaymie Strecker
jstrecker at kosada.com





More information about the cfe-dev mailing list