diff --git a/docs/Static-Analysis/0-LLVM.md b/docs/Static-Analysis/0-LLVM.md new file mode 100644 index 0000000..c48e02e --- /dev/null +++ b/docs/Static-Analysis/0-LLVM.md @@ -0,0 +1,51 @@ +## LLVM + +[19_LLVM.pdf (xiongyingfei.github.io)](https://xiongyingfei.github.io/SA/2017/19_LLVM.pdf) + +### LLVM Basic + +LLVM is **a compiler infrastructure** designed as a set of reusable libraries with well-defined interfaces. + +Big pictures of LLVM: + +- LLVM implements the entire compilation flow + compilation +- off-the-shell optimizations + - Virtual Register Allocation + - Constant Propagation + + + +### LLVM IR + +LLVM Core Hierarchy +LLVM-core-hierarchy + +- Module +- Function +- Value + - local start with `%`, global with $@$ + - Type +- Basic & Instruction + + + +### LLVM Pass + +[LLVM: llvm::Pass Class Reference](https://llvm.org/doxygen/classllvm_1_1Pass.html) + +- Passes perform the **transformations and optimizations** that make up the compiler, + they **build the analysis results** that are used by these transformations, + and they are, above all, **a structuring technique** for compiler code. +- One of the main features of the LLVM Pass Framework is that it schedules passes to run in an efficient way based on the constraints that your pass meets (which are indicated by which class they derive from). + +- LLVM applies a chain of analyses and transformations on the target program. + Each of these analyses or transformations is called a **pass**. + Some passes, which are machine independent, are invoked by *opt*. + A pass may require information provided by other passes. Such dependencies must be explicitly stated. + +- A pass is an instance of the LLVM class `Pass`, `Pass` is the **base class** of all the pass + Pass Class + + + diff --git a/docs/Static-Analysis/5-Interprocedural Analysis.md b/docs/Static-Analysis/5-Interprocedural Analysis.md index 6bdbc4f..ef56e72 100644 --- a/docs/Static-Analysis/5-Interprocedural Analysis.md +++ b/docs/Static-Analysis/5-Interprocedural Analysis.md @@ -1,26 +1,22 @@ -# Interprocedural An +# Interprocedural Analysis -**阅读提示:使用屏幕较大的设备能够看到自带的Sticky Table of Contents,更有利于理清阅读思路。** +## 过程间分析简介 -对应视频在: +本小节通过四个部分介绍过程间分析。 -* [第七课-过程间分析](https://www.bilibili.com/video/BV1GQ4y1T7zm) -* [第八课-指针分析](https://www.bilibili.com/video/BV1gg4y1z78p) +Motivation +* **为什么** 要引入过程间分析? -## 过程间分析简介 +Call Graph Construction \(CHA\) +* 介绍一个过程间分析 **必要的数据结构Call Graph** +* 当前有数种方法来**构建Call Graph**,本节介绍其中**速度最快的一种(Class hierarchy analysis,简称CHA)** -本小节通过四个部分介绍过程间分析。 +Interprocedural Control-Flow Graph +* 之前的章节关注CFG,引入过程间分析后,我们向CFG中**添加相应的元素**,得到过程间的控制流图(ICFG) +* 讨论由于添加了新元素而需要**增加的操作** -1. Motivation - * **为什么** 要引入过程间分析? -2. Call Graph Construction \(CHA\) - * 介绍一个过程间分析 **必要的数据结构Call Graph** - * 当前有数种方法来**构建Call Graph**,本节介绍其中**速度最快的一种(Class hierarchy analysis,简称CHA)** -3. Interprocedural Control-Flow Graph - * 之前的章节关注CFG,引入过程间分析后,我们向CFG中**添加相应的元素**,得到过程间的控制流图(ICFG) - * 讨论由于添加了新元素而需要**增加的操作** -4. Interprocedural Data-Flow Analysis - * 通过一个例子(也就是实验一中做的常量传播分析)来**总结**过程间分析。 +Interprocedural Data-Flow Analysis +* 通过一个例子(也就是实验一中做的常量传播分析)来**总结**过程间分析。 ## Motivation @@ -28,7 +24,7 @@ ![](https://picgo-wbyz.oss-cn-nanjing.aliyuncs.com/202311011954944.png) -## Call Graph Construction \(CHA\) +## Call Graph Construction 接下来我们讨论一个必要的数据结构Call Graph,中文可以理解为调用关系图。 @@ -85,7 +81,7 @@ A:分别调用A和C中定义的foo方法。 ![](https://picgo-wbyz.oss-cn-nanjing.aliyuncs.com/202311011954575.png) -## Class Hierarchy Analysis \(CHA\) +## Class Hierarchy Analysis ### Definition of CHA @@ -267,12 +263,15 @@ Edge transfer处理引入的call & return edge。为此,我们需要**在之 ## Key points -1. How to build call graph via class hierarchy analysis - * 如何利用CHA构建调用关系图\(call graph\) -2. Concept of interprocedural control-flow graph - * 过程间控制流图\(ICFG\)的概念 -3. Concept of interprocedural data-flow analysis - * 过程间数据流分析的概念 -4. Interprocedural constant propagation - * 例子——引入过程间分析的常量分析 +How to build call graph via class hierarchy analysis +* 如何利用CHA构建调用关系图\(call graph\) + +Concept of interprocedural control-flow graph +* 过程间控制流图\(ICFG\)的概念 + +Concept of interprocedural data-flow analysis +* 过程间数据流分析的概念 + +Interprocedural constant propagation +* 例子——引入过程间分析的常量分析