When Dataflow Analysis Meets Large Language Models
Authors:
- Chengpeng WangCWChengpeng Wang
- Wuqi ZhangWZWuqi Zhang
- Zian SuZSZian Su
- Xiangzhe XuXXXiangzhe Xu
- Xiaoheng XieXXXiaoheng Xie
- Xiangyu ZhangXZXiangyu Zhang
Preprint
Abstract
Dataflow analysis is a powerful code analysis technique that reasons dependencies between program values, offering support for code optimization, program comprehension, and bug detection. Existing approaches require the successful compilation of the subject program and customizations for downstream applications. This paper introduces LLMDFA, an LLM-powered dataflow analysis framework that analyzes arbitrary code snippets without requiring a compilation infrastructure and automatically synthesizes downstream applications. Inspired by summary-based dataflow analysis, LLMDFA decomposes the problem into three sub-problems, which are effectively resolved by several essential strategies, including few-shot chain-of-thought prompting and tool synthesis. Our evaluation has shown that the design can mitigate the hallucination and improve the reasoning ability, obtaining high precision and recall in detecting dataflow-related bugs upon benchmark programs, outperforming state-of-the-art (classic) tools, including a very recent industrial analyzer.Keywords
All Related Versions
This publication has 25 references indexed in Scilit:
- Can ChatGPT support software verification?2024
- Generating Variable Explanations via Zero-shot Prompt Learning2023
- Juliet 1.1 C/C++ and Java Test SuiteComputer, 2012
- Compositional shape analysis by means of bi-abduction2009
- The Daikon system for dynamic detection of likely invariantsScience of Computer Programming, 2007
- LLVM: A compilation framework for lifelong program analysis & transformation2004
- Partial dead code elimination using slicing transformations1997
- Points-to analysis in almost linear time1996
- Precise interprocedural dataflow analysis via graph reachability1995
- An efficient data dependence analysis for parallelizing compilersIEEE Transactions on Parallel and Distributed Systems, 1990