LLVM daily talk of fifty-five On the wrong perception of and reasons Pass

Pass as an important part of a LLVM, the LLVM IR level and LLVM Backend levels have played an important role. Many LLVM Pass users will easily be understood as LLVM IR-level analysis and transform, while ignoring the role Pass in LLVM Backend level. In fact, Pass in LLVM Backend level role that is not small. After the end of the structure as an example:

Notes: 《Getting Started with LLVM Core Libraries》P134.

"Getting Started with LLVM Core Libraries" of the contents of the box blank to write directly to Pass, content with gray boxes interpreted as a super Pass composed of several small Pass. According to this view, Pass can be understood as the main part of the whole back end. Of course, the back end is not entirely Pass, but from the point of view of process execution, Pass participated in the main part of the whole back end.

Why, then, the back end of Pass always so easy to be ignored?

First, sub-categories and sub-categories from the Pass subclass talking about. Pass subclasses are:

Among them, we use the most is the level of LLVM IR FunctionPass. The LLVM Backend in the Pass, mainly MachineFunctionPass parent class. And MachineFunctionPass is FunctionPass subclass, the structure shown:

On this structure, MachineFunctionPass is a structural weak point, if you ignore the Pass, Pass directly overlooked in the use of the back-end, unlike the LLVM IR level, all of the Pass subclasses are using.

Secondly, another reason causing many people to Pass and Backend unrelated to that source directory. Many people are concerned Pass just in lib / Analysis directory and lib / Transfrom directory, ignoring the lib / Codegen directory and lib / directory contents Target, it creates the illusion Pass is only used on LLVM IR level.

再次,对LLVM IR层面和LLVM Backend层面的Pass的调用方式不同,也导致很多使用者将二者割裂开来。LLVM IR层面,使用的是opt工具;LLVM Backend层面,使用的是llc工具。

最后,一些使用者忽略Pass在Backend应用是因为对后端的认识比较模糊,没有搞清楚后端的完整架构。默认的将Pass直接和LLVM IR层面进行了绑定。


相关内容:

小乖他爹:LLVM每日谈之四 Pass初探

小乖他爹:LLVM每日谈之八 PASS例子分析

小乖他爹:LLVM每日谈之十二 LLVM的源码分析之Pass相关

小乖他爹:LLVM每日谈之十三 使用LLVM自带的PASS

小乖他爹:LLVM每日谈之四十二 一个添加pass的实例

小乖他爹:LLVM每日谈之四十三 LLVM的utility pass

发布于 2019-06-13

Guess you like

Origin blog.csdn.net/snsn1984/article/details/92208556