A Learning-Based Approach to Static Program Slicing
Aashish Yadavally, Yi Li, Shaohua Wang, Tien N. Nguyen
Abstract
Traditional program slicing techniques are crucial for early bug detection and manual/automated debugging of online code snippets. Nevertheless, their inability to handle incomplete code hinders their real-world applicability in such scenarios. To overcome these challenges, we present NS-Slicer, a novel learning-based approach that predicts static program slices for both complete and partial code. Our tool leverages a pre-trained language model to exploit its understanding of fine-grained variable-statement dependencies within source code. With this knowledge, given a variable at a specific location and a statement in a code snippet, NS-Slicer determines whether the statement belongs to the backward slice or forward slice, respectively.
We conducted a series of experiments to evaluate NS-Slicer's performance. On complete code, it predicts the backward and forward slices with an F1-score of 97.41% and 95.82%, respectively, while achieving an overall F1-score of 96.77%. Notably, in 85.20% of the cases, the static program slices predicted by NS-Slicer exactly match entire slices from the oracle. For partial programs, it achieved an F1-score of 96.77%-97.49% for backward slicing, 92.14%-95.40% for forward slicing, and an overall F1-score of 94.66%-96.62%. Furthermore, we demonstrate NS-Slicer's utility in vulnerability detection (VD), integrating its predicted slices into an automated VD tool. In this setup, the tool detected vulnerabilities in Java code with a high F1-score of 73.38%. We also include the analyses studying NS-Slicer's promising performance and limitations, providing insights into its understanding of intrinsic code properties such as variable aliasing, leading to better slicing.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 7441bc92-daf0-4b70-a546-9a7ab0a72f9dCited by top-tier papers7
- SelfPiCo: Self-Guided Partial Code Execution with LLMsZhipeng Xue, Zhipeng Gao, Shaohua Wang, Xing Hu et al.ISSTA 2024 · 8 citations
- Your Fix Is My Exploit: Enabling Comprehensive DL Library API Fuzzing with Large Language ModelsKunpeng Zhang, Shuai Wang, Jitao Han, Xiaogang Zhu et al.ICSE 2025 · 6 citations
- NESA: Relational Neuro-Symbolic Static Program AnalysisChengpeng Wang, Yifei Gao, Wuqi Zhang, Xuwei Liu et al.FSE 2026 · 1 citation
- Large Language Model-Aided Partial Program Dependence AnalysisXiaokai Rong, Aashish Yadavally, Tien N. NguyenICSE 2026 · 1 citation
- The Path Not Taken: Duality in Reasoning about Program ExecutionEshgin Hasanov, Md. Mahadi Hassan, Santu Karmaker, Aashish YadavallyACL 2026
Builds on9
- GraphCodeBERT: Pre-training Code Representations with Data FlowDaya Guo, Shuo Ren, Shuai Lu, Zhangyin Feng et al.ICLR 2021 · 1,644 citations
- Stack Overflow Considered Harmful? The Impact of Copy&Paste on Android Application SecurityFelix Fischer, Konstantin Böttinger, Huang Xiao, Christian Stransky et al.S&P 2017 · 293 citations
- LongCoder: A Long-Range Pre-trained Language Model for Code CompletionDaya Guo, Canwen Xu, Nan Duan, Jian Yin et al.ICML 2023 · 150 citations
- VulCNN: An Image-inspired Scalable Vulnerability Detection SystemYueming Wu, Deqing Zou, Shihan Dou, Wei Yang et al.ICSE 2022 · 141 citations
- TRACED: Execution-aware Pre-training for Source CodeYangruibo Ding, Benjamin Steenhoek, Kexin Pei, Gail E. Kaiser et al.ICSE 2024 · 29 citations
Related papers
- Predictive Program Slicing via Execution Knowledge-Guided Dynamic Dependence LearningAashish Yadavally, Yi Li, Tien N. NguyenFSE 2024 · 4 citations
- (Partial) Program Dependence LearningAashish Yadavally, Tien N. Nguyen, Wenbo Wang, Shaohua WangICSE 2023 · 6 citations
- SLICEFORMER: Static Program Slicing Using Language Models With Dataflow-Aware Pretraining and Constrained DecodingPengfei He, Shaowei Wang, Tse-Hsun Chen, Muhammad AsaduzzamanACL 2026
- Blended Analysis for Predictive ExecutionYi Li, Hridya Dhulipala, Aashish Yadavally, Xiaokai Rong et al.FSE 2025 · 1 citation
- Web Application Vulnerability Repair Via Context-Aware Fault Localization and Directed Differential FuzzingChenlin Wang, Wei MengS&P 2026
