一句话:提出流类型感知的IR预训练模型FAIR,用图Transformer与五项预训练任务,在四个下游任务上取得SOTA。
现有基于编译器中间表示(IR)的预训练模型通常利用指令、控制数据流图(CDFG)、调用图等特征,但它们在CDFG中混淆变量节点与指令节点,且不区分不同流类型;所用神经网络也难以捕获长距离依赖,并存在过平滑与过挤压问题。为此,本文提出FAIR,一种流类型感知的IR预训练模型。FAIR包含三方面设计:新的IR程序输入表示,用于区分变量/指令节点及流类型;采用Graph Transformer以缓解过平滑、过挤压并建模长距离依赖;提出五个预训练任务,使模型学习IR token语义、流类型信息以及IR整体表示。实验结果表明,FAIR在四个代码相关下游任务上均达到当时最优效果,验证了流类型感知表示与图Transformer在IR预训练中的有效性。
While the majority of existing pre-trained models from code learn source code features such as code tokens and abstract syntax trees, there are some other works that focus on learning from compiler intermediate representations (IRs). Existing IR-based models typically utilize IR features such as instructions, control and data flow graphs (CDFGs), call graphs, etc. However, these methods confuse variable nodes and instruction nodes in a CDFG and fail to distinguish different types of flows, and the neural networks they use fail to capture long-distance dependencies and have over-smoothing and over-squashing problems. To address these weaknesses, we propose FAIR, a Flow type-Aware pre-trained model for IR that involves employing (1) a novel input representation of IR programs; (2) Graph Transformer to address over-smoothing, over-squashing and long-dependencies problems; and (3) five pre-training tasks that we specifically propose to enable FAIR to learn the semantics of IR tokens, flow type information, and the overall representation of IR. Experimental results show that FAIR can achieve state-of-the-art results on four code-related downstream tasks.