ComBack: A Versatile Dataset for Enhancing Compiler Backend Development Efficiency

Ming Zhong, Fang Lyu, Lulin Wang, Hongna Geng, Lei Qiu, Huimin Cui, Xiaobing FengNeurIPS 2024

TL;DR

Researchers have introduced ComBack, the first large-scale public dataset specifically designed to help Large Language Models (LLMs) assist in compiler backend development. By fine-tuning a relatively small 220M parameter model (CodeT5+) on this data, the authors outperformed massive general-purpose models like ChatGPT and Code-LLaMA-34B, potentially slashing the manual effort required to support new hardware.

The Bottleneck in Compiler Development

Every time a new processor (CPU, GPU, or MPU) is designed, engineers must write a "compiler backend" to translate high-level code into that specific chip's machine instructions. This is a notoriously grueling, manual process. Currently, developers rely on a "Fork-Flow" method—finding a similar existing backend, forking the code, and manually tweaking it for the new architecture.

Conventional vs. ComBack Workflow

While LLMs have revolutionized general software engineering, they struggle with compiler backends. This is because backend code is highly specialized, filled with target-specific values (like instruction encodings and register names), and—until now—lacked a dedicated, high-quality dataset for training.

Methods and the ComBack Dataset

The authors developed a pipeline to crawl, clean, and structure backend code from GCC and LLVM repositories. A key technical contribution is their Target-Specific Value Extraction. Since every chip has different numerical constants and flags, the researchers replaced these with intermediate representations (e.g., <NUM_LIT> for numbers, <STR_LIT> for strings). This allows the model to learn the logic and structure of a backend without getting tripped up by the specific bit-patterns of a single chip.

The resulting ComBack dataset is sourced from 317 GitHub repositories and official compiler sites.

  • Scale: It includes 178 backends (77 for GCC, 101 for LLVM).
  • Volume: Roughly 43,000 functions for GCC and 138,000 for LLVM, totaling over 5.7 million lines of code (KLoC).
  • Diversity: It covers a wide array of architectures, including CPUs, GPUs, MPUs, DSPs, and VLIW processors.

To evaluate model performance, the researchers defined three specific tasks: Statement-Level Completion, Next-Statement Suggestion, and Code Generation (writing a whole function based on a natural language description).

Key Insights

The "Common Core" of Backends

The researchers found that across 25 LLVM targets, an average of 57.6% of functions are "inherited" from the compiler's general infrastructure, rather than being entirely custom-written from scratch.

Proportion of Inherited vs. Customized Functions

This commonality is exactly what the LLM learns to exploit, helping it "guess" how a new backend should be structured based on its knowledge of others.

Domain Specificity Trumps Scale

The most striking insight is that a specialized 220M parameter model can beat a 34B parameter model. This suggests that for niche engineering tasks, high-quality, domain-specific data is far more valuable than raw model size. Furthermore, the dataset supports "iterative expansion." When the authors added a small amount of data for a specific customized target, the model's accuracy for that target jumped significantly, proving the dataset can grow alongside new hardware trends.

Key Results

The authors tested six models, with CodeT5+ emerging as the top performer.

  • Beating the Giants: In statement-level completion, the fine-tuned CodeT5+ (220M) outperformed ChatGPT-3.5 by over 40% and Code-LLaMA-34B by over 50% in absolute Exact Match (EM) accuracy.
  • Surpassing Manual Baselines: When compared against the traditional "Fork-Flow" method, the ComBack-trained model achieved higher BLEU-4 scores and lower Edit Distances, meaning it generates code that is closer to the final "ground truth" than a human starting from a template.
  • Cross-Target Success: The model successfully generalized from CPU data to generate code for MPUs and GPUs, though with a slight but manageable dip in accuracy.

Limitations and Future Work

The primary limitation acknowledged by the authors is the lack of natural language descriptions for highly customized functions. While many standard functions have documentation, the highly specialized parts of a backend often lack the comments needed to train a "text-to-code" model effectively. Future work will focus on gathering more descriptive metadata for these custom components and exploring how to better support "new-to-the-world" architectures that don't share common ancestry with existing targets.

Summary updated

BibTeX
@inproceedings{zhong2024comback,
  author = {Ming Zhong and FANG LYU and Lulin Wang and Hongna Geng and Lei Qiu and Huimin Cui and Xiaobing Feng},
  title = {{ComBack: A Versatile Dataset for Enhancing Compiler Backend Development Efficiency}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=vfju5hjrJw},
}
Figure