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},
title = {Graph Neural Networks in Program Analysis},
editor = {Wu, Lingfei and Cui, Peng and Pei, Jian and Zhao, Liang},
booktitle = {Graph Neural Networks: Foundations, Frontiers, and Applications},
publisher = {Springer},
address = {Singapore},
year = {2021},
pages = {483-497},
chapter = {22},
}