aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/NaCl/ExpandVarArgs.cpp
AgeCommit message (Collapse)Author
2014-03-03Fix alignment of vararg buffer allocas.Dan Gohman
Since we do 8-byte loads for va_arg of double, make sure the vararg buffer alloca is 8-byte aligned.
2014-02-25Support GEP and ConstantExprs directly in the JSBackend.Dan Gohman
This patch also lays the groundwork for the single-use instruction trick to reduce the number of temporary variables.
2014-01-10lower resumeAlon Zakai
2014-01-10wip better approach to exceptionsAlon Zakai
2013-11-29do not simplify varargs calls to jsargs emscripten intrinsics, that want ↵Alon Zakai
normal js args to be passed, and disable unneeded createExpandSmallArgumentsPass
2013-11-21align varargs stack writes to the proper 4-byte boundariesAlon Zakai
2013-06-03PNaCl: ExpandVarArgs: Use memcpy() instead of struct load+store for struct argsMark Seaborn
Although PNaCl doesn't fully support struct types as varargs arguments, there is a test in Spec2k (255.vortex) that passes a struct as a varargs argument but never reads the argument using va_arg (which is legal, but strange). ExpandVarArgs was handling the struct argument by copying it with a struct load+store. This is undesirable because currently SROA converts that into code that uses extractvalue, which was rejected by the PNaCl ABI checker. Struct load/store will soon be rejected by the ABI checker too. We could fix this by running ExpandStructRegs after ExpandVarArgs, but it's cleaner for ExpandVarArgs to use memcpy() instead of struct load+store. memcpy() is potentially more efficient because it avoids having a temporary copy of the struct, and using memcpy() avoids dependencies between IR passes. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3338 BUG=https://code.google.com/p/nativeclient/issues/detail?id=3343 TEST=*.ll tests + built 255.vortex from Spec2k Review URL: https://codereview.chromium.org/16232021
2013-05-29PNaCl: Add ExpandSmallArguments pass to widen parameters to 32 bitsMark Seaborn
This widens i1, i8 and i16 function arguments and return types. Factor out RecreateFunction() helper function from existing PNaCl passes since this is a reoccurring code fragment. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3342 TEST=*.ll tests + PNaCl toolchain trybots + GCC torture tests + LLVM test suite Review URL: https://codereview.chromium.org/15971007
2013-05-22PNaCl: Add ReplacePtrsWithInts pass for stripping out pointer typesMark Seaborn
ReplacePtrsWithInts converts IR to a normal form in which functions don't reference any aggregate pointer types and pointer types only appear inside a few instructions. Change BlockAddress::replaceUsesOfWithOnConstant() to handle changing a function's type by replacing a function with a bitcast ConstantExpr of a new function. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3343 TEST=replace-ptrs-with-ints.ll + PNaCl toolchain trybots, torture tests, etc. Review URL: https://codereview.chromium.org/14262011
2013-05-09PNaCl: Add NoAlias attributes in ExpandByVal and ExpandVarArgs passesMark Seaborn
This could help prevent these expansion passes from inhibiting optimisations than run after the expansion. e.g. It gives the optimiser more freedom to move around reads from the varargs buffer because they will not alias writes to other locations. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3400 TEST=PNaCl toolchain trybots + GCC torture tests + LLVM test suite + Spec2k Review URL: https://codereview.chromium.org/14060026
2013-04-29Use unique'ed types for varargs expansion instead of non-unique named types.Jan Voung
Saves a tiny bit of space for var-args heavy bitcode programs, since the anonymous types get unique'ed. E.g., saves 20KB out of 1.6MB in spec gcc when comparing the gzipped files, or about 100KB when not zipped. This is only a savings with the current wire format. If we change the alloca, etc. to only have sizes and not struct types then we would also not have this duplication. Just happened to notice while looking through code for what struct types remain used in the bitcode. random cleanup for: BUG= https://code.google.com/p/nativeclient/issues/detail?id=3338 R=mseaborn@chromium.org Review URL: https://codereview.chromium.org/14197004
2013-04-04PNaCl: Change ExpandVarArgs to work around invalid use of va_argMark Seaborn
I've encountered two uses of va_arg on an empty argument list: NaCl's open() wrapper (now fixed), and 176.gcc in Spec2k. Although this is invalid use of va_arg (giving undefined behaviour), it's too awkward to fix 176.gcc. Work around this invalid usage by ensuring that the argument list pointer points to a location on the stack rather than being uninitialised. va_arg will return undefined values as it does in the usual native ABIs, rather than crashing. We could add options for non-strict and strict modes (possibly with a bounds check), but that's too much complication for now. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3338 TEST=test/Transforms/NaCl/*.ll + ran 176.gcc from Spec2k Review URL: https://codereview.chromium.org/13510004
2013-03-27PNaCl: Fix ExpandVarArgs to handle "byval" struct arguments properlyMark Seaborn
* Ensure that the "byval" attribute is preserved for the fixed arguments. Before, it was stripped off from function calls but left in for function definitions, which broke passing struct arguments (which PNaCl Clang generates as "byval"). * Ensure that function and return attributes are preserved too. * Handle "byval" variable arguments in calls too by dereferencing the pointer. These are not yet usable with PNaCl Clang, which does not allow va_arg on structs (see https://code.google.com/p/nativeclient/issues/detail?id=2381), but we might as well make this pass ready to handle this. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3338 TEST=test/Transforms/NaCl/expand-varargs*.ll Review URL: https://codereview.chromium.org/13100002
2013-03-21PNaCl: Add ExpandVarArgs pass for expanding out variable-args function callsMark Seaborn
Once this pass is enabled, it will simplify the language to reduce the set of constructs that a PNaCl translator needs to handle as part of a stable wire format for PNaCl. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3338 TEST=test/Transforms/NaCl/expand-varargs.ll Review URL: https://codereview.chromium.org/12481021