计算机工程与应用 ›› 2017, Vol. 53 ›› Issue (24): 40-47.DOI: 10.3778/j.issn.1002-8331.1608-0241

• 理论与研发 • 上一篇    下一篇

基于GCC关键变量数据流分析算法的程序切片技术

杨小川,姜  军,马晓东,漆锋滨   

  1. 江南计算技术研究所,江苏 无锡 214083
  • 出版日期:2017-12-15 发布日期:2018-01-09

Program slicing technology based on critical variable dataflow analysis algorithm in GCC compiler

YANG Xiaochuan, JIANG Jun, MA Xiaodong, QI Fengbin   

  1. Jiangnan Institute of Computing Technology, Wuxi, Jiangsu 214083, China
  • Online:2017-12-15 Published:2018-01-09

摘要: 随着程序的规模的扩大和复杂度的提高,通过直接分析源码进行程序切片,变得十分困难。在现有的利用编译优化技术来优化程序切片的方法中,存在无法有效利用程序的编译时信息和编译器的优化技术,以及对语言的支持不完善的问题。为此,分析了GCC编译器在编译时的中间表示,首次提出了基于GCC关键变量数据流分析算法的程序切片技术,以程序的GIMPLE中间表示为基础,以程序基本块为单位,通过迭代求解数据流方程,分析程序基本块内和不同基本块间的关键变量数据流信息。该程序切片技术可以获取源程序中仅与预设目标函数相关的关键变量和关键语句,缩减程序规模。最后通过实验,证明了该算法的可行性。

关键词: 程序切片, 目标函数, 关键变量, 数据流分析, GIMPLE中间表示

Abstract: With the scale of program increasing and program complexity rising, program slicing through direct code analysis becomes much harder. In the existed approaches that use compiler optimization techniques for obtaining more accurate slices, compile-time information and existed compiler optimization are overlooked, program languages are not fully supported. To solve this problem, this paper analyzes the intermediate representations of GCC compiler, and proposes a program slicing technology based on critical variable dataflow analysis algorithm in GCC compiler. This algorithm collects dataflow information both within and between basic blocks through iteratively solving the dataflow equations, which is based on GIMPLE intermediate representation and processes a basic block in each time. The proposed technique can find the critical variables and critical statements relevant to target function, and reduces the scale of the sliced program. The results of experiment show that the proposed algorithm is feasible.

Key words: program slicing, target function, critical variants, data flow analysis, GIMPLE intermediate representation