Make struct passing work properly

this is ~~a first cut at~~ rebasing #3466 onto master. @Keno let me know if you see anything that looks wrong.

 - [ ] I have not tested it on windows yet. (only linux 32/64 and mac 64)

To keep track of issues (from comments) from the previous PR:

 - [x] Need to add link to LDC
 - [x] ~~Need to figure out what to do with fixed-size arrays.~~

I'm not sure right now. I seem to recall this function also being implemented in C, so we should match whatever is done there.