电子学报 ›› 2012, Vol. 40 ›› Issue (11): 2171-2176.DOI: 10.3969/j.issn.0372-2112.2012.11.005

• 学术论文 • 上一篇    下一篇

基于模拟关系的编译优化实现正确性验证方法

徐超1,2,3, 何炎祥1,3, 吴伟1,3, 陈勇1,3, 刘健博1,3   

  1. 1. 武汉大学计算机学院,湖北武汉 430072;
    2. 徐州工业职业技术学院,江苏徐州 221000;
    3. 软件工程国家重点实验室,湖北武汉 430072
  • 收稿日期:2012-03-15 修回日期:2012-06-13 出版日期:2012-11-25 发布日期:2012-11-25
  • 作者简介:徐 超 男,1980年出生,湖北红安人,博士生,讲师,CCF会员(E200019473G),研究方向为可信软件和嵌入式系统. E-mail:xuch@whu.edu.cn 何炎祥 男,1952年出生,湖北应城人,博士,教授,博士生导师,研究方向为可信软件、并行分布处理、软件工程和嵌入式系统. E-mail:yxhe@whu.edu.cn 吴 伟 男,1985年,河南新县人,博士生,研究方向为可信软件和编译理论. E-mail:wuwei@whu.edu.cn 陈 勇 男,1986年出生,湖南冷水江人,博士生,研究方向为可信软件和嵌入式系统. E-mail:cyong@whu.edu.cn
  • 基金资助:
    国家自然科学基金重点项目(No.91118003);国家自然科学基金面上项目(No.61170022)

Verifying Implementation Correctness of Compiling Optimization Based on Simulation Relation

XU Chao1,2,3, HE Yan-xiang1,3, WU Wei1,3, CHEN Yong1,3, LIU Jian-bo1,3   

  1. 1. Wuhan University Computer of School,Wuhan,Hubei 430072,China;
    2. Xuzhou College of Industrial Technology,Xuzhou,Jiangsu 221000,China;
    3. State Key Laboratory of Software Engineering,Wuhan,Hubei 430072,China
  • Received:2012-03-15 Revised:2012-06-13 Online:2012-11-25 Published:2012-11-25

摘要: 编译器中通常采用各种优化方法来提高目标代码的质量,为了实现较好的效果,一些编译优化算法通常十分复杂,很容易给可靠性和安全性带来隐患.现有的编译器缺陷大部分是由优化阶段引起的.传统的编译优化正确性研究大部分只关注优化算法的正确性,但是只有该算法被正确的实现了才能确保实际运行的优化过程是正确的.本文提出一种基于模拟关系的方法来验证编译优化实现的正确性.在每次优化结束后,我们通过建立优化前代码和优化后代码之间的模拟关系生成优化正确应满足的逻辑条件,然后验证逻辑条件是否成立从而判定编译优化的实现是否正确性.以优化编译中的常量折叠优化和变量替换的验证作为示例显示了本方法的有效性和可靠性.

关键词: 编译优化, 正确性, 模拟关系, 定理证明

Abstract: Many optimization methods are used to raise the quality of target code in the process of compiling.Because some optimization methods for compiling are too complicated,hidden dangers won't be avoided for reliability and security of compiling.The existing defects of compiler are usually caused at the optimization phase.Mostly traditional correctness of compiling optimization only focus on correctness of optimization algorithm,but only when the algorithm is implemented correctly,the optimization process run in practice can be proved to be correct.This paper proposes a method based on simulation relation to verify correctness of compiling optimization realization.We build up simulation relation between code before optimization and code after optimization to generate logic condition that the correctness optimization should satisfy,and then we verify it if logic condition is satisfied or not to judge if compiling optimization realization is correct or not after each optimization is finished.The method is proved to be effective and reliable by verifying statement exchange and variable substitution in the process of optimization compiling.

Key words: compiling optimization, correctness, simulation relation, theorem proving

中图分类号: