This is a preliminary patch for varargs support. It doesn't all work yet, and is quite untested. I'm just sending out the patch for comments.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Looks simpler than I thought it would be!
lib/Target/WebAssembly/WebAssemblyISelLowering.cpp | ||
---|---|---|
309 ↗ | (On Diff #41880) | This is just extra validation, unrelated to varargs? No need to split it out, I just want to make sure I'm not missing something. |
335 ↗ | (On Diff #41880) | This is pretty much the same approach as PNaCl, but done right. IIUC: varargs are effectively in a naturally-aligned struct at the top of stack, and the callee gets a pointer to the stark. Is that correct? If so, could the comment explain that part? |
367 ↗ | (On Diff #41880) | This just appends the fixed args, and doesn't append anything related to varags, correct? |
450 ↗ | (On Diff #41880) | Duplicated above. Factor out? |
Roughly the same patch, but with some of the uninteresting bits split out, and some extra comments.
One thing slightly different about this varargs implementation from the PNaCl LowerVarArgs pass is that this implementation doesn't pass a pointer argument; it just puts the varargs arguments at the top of the stack, so they are pointed to by the stack pointer (or from the callee's perspective, by the frame pointer). We could go either way, but I don't think it makes a difference in performance (and besides, this is varargs ;-)), and I think it's a little tidier this way.
lib/Target/WebAssembly/WebAssemblyISelLowering.cpp | ||
---|---|---|
316 ↗ | (On Diff #41894) | That's right. I decided to just split it out now, so it's out of the way. |
342 ↗ | (On Diff #41894) | Comments added. |
375 ↗ | (On Diff #41894) | I added a comment explaining this. |
459 ↗ | (On Diff #41894) | Done. |
Various fixes and cleanups. And add a testcase. Note that va_start and actual arguments don't work yet; they depend on frame pointer support. All the tests pass with this patch applied, so I think it's ready to land.
lib/Target/WebAssembly/WebAssemblyISelLowering.cpp | ||
---|---|---|
338 ↗ | (On Diff #41943) | Add a comment string to the assert. |
363 ↗ | (On Diff #41943) | Ditto. |
444 ↗ | (On Diff #41943) | Typo? |
lib/Target/WebAssembly/WebAssemblyRegStackify.cpp | ||
207 ↗ | (On Diff #41943) | Does this happen because of varargs? Could you comment. |
test/CodeGen/WebAssembly/varargs.ll | ||
126 ↗ | (On Diff #41943) | No need for the attributes. |