Input-Gen: Guided Generation of Stateful Inputs for Testing, Tuning, and Training
Ivan R. Ivanov, Joachim Meyer, Aiden Grossman, William S. Moses, Johannes Doerfert
TL;DR
The paper tackles the scarcity of dynamic execution data for training and evaluating code-focused models by proposing a scalable, stateful input generation framework that can operate across languages compiled to LLVM. It introduces an LLVM-based instrumentation pass and two runtimes (generation and replay) to produce initial memory states and arguments and to replay executions for a given function, enabling practical testing, tuning, and ML training workflows. Key results show a high scalability and coverage: instrumentation of about $99\%$ of modules and replay success for about $90\%$ across roughly $21.5$ million functions, with block coverage rising from $37\%$ to $45\%$ when using five inputs. The work enables large-scale, realistic input datasets and paves the way for data-driven compiler analysis and ML-assisted code reasoning by providing reusable, stateful test inputs across languages and architectures.
Abstract
The size and complexity of software applications is increasing at an accelerating pace. Source code repositories (along with their dependencies) require vast amounts of labor to keep them tested, maintained, and up to date. As the discipline now begins to also incorporate automatically generated programs, automation in testing and tuning is required to keep up with the pace - let alone reduce the present level of complexity. While machine learning has been used to understand and generate code in various contexts, machine learning models themselves are trained almost exclusively on static code without inputs, traces, or other execution time information. This lack of training data limits the ability of these models to understand real-world problems in software. In this work we show that inputs, like code, can be generated automatically at scale. Our generated inputs are stateful, and appear to faithfully reproduce the arbitrary data structures and system calls required to rerun a program function. By building our tool within the compiler, it both can be applied to arbitrary programming languages and architectures and can leverage static analysis and transformations for improved performance. Our approach is able to produce valid inputs, including initial memory states, for 90% of the ComPile dataset modules we explored, for a total of 21.4 million executable functions. Further, we find that a single generated input results in an average block coverage of 37%, whereas guided generation of five inputs improves it to 45%.
