Chapter22: Graph Neural Networks in Program Analysis

Miltiadis Allamanis, Microsoft Research, miallama@microsoft.com

Abstract

Program analysis aims to determine if a program’s behavior complies with some specification. Commonly, program analyses need to be defined and tuned by humans. This is a costly process. Recently, machine learning methods have shown promise for probabilistically realizing a wide range of program analyses. Given the structured nature of programs, and the commonality of graph representations in program analysis, graph neural networks (GNN) offer an elegant way to represent, learn, and reason about programs and are commonly used in machine learning-based program analyses. This chapter discusses the use of GNNs for program analysis, highlighting two practical use cases: variable misuse detection and type inference.

Contents

  • Introduction
  • Machine Learning in Program Analysis
  • A Graph Representation of Programs
  • Graph Neural Networks for Program Graphs
  • Case Study: Detecting Variable Misuse Bugs
  • Case Study: Predicting Types in Dynamically Typed Languages
  • Future Directions

Citation

@incollection{GNNBook-ch22-allamanis,
author = "Allamanis, Miltiadis",
editor = "Wu, Lingfei and Cui, Peng and Pei, Jian and Zhao, Liang",
title = "Graph Neural Networks in Program Analysis",
booktitle = "Graph Neural Networks: Foundations, Frontiers, and Applications",
year = "2022",
publisher = "Springer Singapore",
address = "Singapore",
pages = "483--497",
}

M. Allamanis, “Graph neural networks in program analysis,” in Graph Neural Networks: Foundations, Frontiers, and Applications, L. Wu, P. Cui, J. Pei, and L. Zhao, Eds. Singapore: Springer Singapore, 2022, pp. 483–497.