Abstract Static call graphs are essential for automated program analysis, yet they frequently include numerous "false positive" edges that never occur during runtime. These spurious edges degrade the performance of downstream bug-finding and optimization tools. We present AutoPruner, a deep-learning-based tool that prunes call graphs by integrating traditional structural features with semantic code representations. By leveraging a fine-tuned CodeBERT model, AutoPruner achieves superior precision in identifying legitimate call edges. Our evaluation shows that AutoPruner reduces the false alarm rate of null pointer analysis from 73% to 12%, significantly enhancing the utility of static analysis tools.
Introduction
In software engineering, a call graph serves as a fundamental map of function invocations within a program. These graphs are critical for tools designed to detect bugs, perform security audits, or optimize code. However, generating these graphs statically—without executing the code—presents a significant challenge. To ensure "soundness" (not missing any real calls), static analysis tools often over-approximate, leading to a high volume of false-positive edges. In some instances, over 75% of the edges in a generated call graph may be non-existent at runtime.
Previous pruning techniques primarily relied on structural graph metrics, such as node degree or connectivity. While useful, these methods struggle with complex coding patterns where legitimate calls appear structurally similar to spurious ones. The authors of AutoPruner argue that effective pruning requires an understanding of program semantics—the actual logic and intent behind the source code.
Methodology
AutoPruner employs a hybrid approach to classify call graph edges as either true positives or false positives. The system architecture is divided into three main phases: fine-tuning, training, and application.
- Semantic Feature Extraction: The core of AutoPruner is a CodeBERT model, a Transformer-based architecture pre-trained on vast repositories of source code. This model is fine-tuned to recognize the relationship between a "caller" function and a "callee" function. By processing the source code of both functions, the model generates a high-dimensional embedding that captures their semantic compatibility.
- Structural Feature Extraction: Complementing the semantic analysis, AutoPruner extracts 22 handcrafted structural features. These include metrics like in-degree/out-degree of nodes and the shortest path from the program's entry point.
- Feature Fusion and Classification: The semantic embeddings and structural features are fused into a single representation and passed to a feed-forward neural network. This classifier determines whether a specific edge should be retained or pruned.
Evaluation and Results
The researchers evaluated AutoPruner using the NJR-1 benchmark, which comprises 141 real-world Java programs. Ground truth for the call graphs was established through extensive dynamic analysis, observing actual function calls during program execution.
AutoPruner demonstrated a marked improvement over existing state-of-the-art methods like cgPruner. It improved the F-measure—a balanced metric of precision and recall—by up to 13%. The most significant impact, however, was observed in downstream "client" analyses.
As shown in the results, using an unpruned "original" graph for null pointer analysis leads to a 73% false alarm rate, rendering the tool nearly unusable for developers. AutoPruner slashes this rate to just 12%. Furthermore, the tool improved the detection of monomorphic call-sites—a key optimization target—by over 10% compared to using raw static call graphs.
Discussion and Key Insights
Ablation studies conducted by the authors revealed that semantic features are the primary driver of AutoPruner's success. Semantic features alone achieved an F-measure of 0.66, whereas structural features alone reached 0.62. The combination of both yielded the peak performance of 0.68.
A critical insight from the research is the importance of context. The model's performance peaks when it analyzes the code of both the caller and the callee, suggesting that the "compatibility" between the two is the most reliable indicator of a real call. This is particularly evident in patterns like the "AcceptState" problem, where a single parser function may legitimately call dozens of different expression types. While a structural pruner might flag these as suspicious due to high out-degree, AutoPruner's semantic understanding allows it to correctly identify them as valid logic.
Limitations and Future Work
Despite its success, AutoPruner has limitations. Its reliance on dynamic analysis for ground truth means that training data is only as good as the test coverage of the benchmark programs. Currently, the tool is optimized for Java; extending it to other languages like C++ or Python would require adapting the pre-processing pipeline. Future research directions include incorporating "k-hop" context (analyzing the caller's caller) and using the model to suggest missing edges in incomplete call graphs.
Summary updated