在LLVM中如何判断二个基本块(Basic Block)的支配关系
来源:互联网 发布:淘宝网店如何运营 编辑:程序博客网 时间:2024/06/05 21:01
一、支配的定义
根据维基百科 支配的概念如下:
控制流图(CFG)的一个节点 d 支配节点 n,当且仅当从开始节点(可以理解为源)到节点 n的每一条路径均要经过节点d,写作d dom n (一写作d \gg n)。根据上述定义,容易得到每个节点均控制其自身。
英文维基百科中提到的一些概念
There are a number of related concepts:
- A node d strictly dominates a node n if d dominates n and d does not equal n.
- The immediate dominator or idom of a node n is the unique node that strictly dominates n but does not strictly dominate any other node that strictly dominates n. Not all nodes have immediate dominators (e.g. entry nodes don't).
- The dominance frontier of a node d is the set of all nodes n such that d dominates an immediate predecessor of n, but d does not strictly dominate n. It is the set of nodes where d's dominance stops.
- A dominator tree is a tree where each node's children are those nodes it immediately dominates. Because the immediate dominator is unique, it is a tree. The start node is the root of the tree.
二、LLVM打印出支配树的遍
我们可以使用命令
opt --help|grep dom来查看LLVM中提供的与支配树相关的遍。
例如可以使用
opt -dot-dom test.ll打印出test.ll的支配树。
三、判断二个基本块(Basic Block)的支配关系
在LLVM中我们可以使用如下代码判断基本块支配关系(需要包含头文件llvm/Analysis/Dominators.h)。
Function* F; ... DominatorTree*T=new DominatorTree(); T->runOnFunction(*F); T->print(errs());//打印出支配树 //打印出函数F所有模块之间的支配关系 for(Function::iterator I=F->begin(),E=F->end();I!=E;I++){ for(Function::iterator J=F->begin(),JE=F->end();J!=JE;J++){ //1表示I支配J,0表示I不支配J errs()<<I->getName()<<" "<<J->getName()<<" "<<T->dominates(I,J)<<"\n"; } }
如果想判断严格支配关系,可以使用函数properlyDominates来替代dominates函数。
0 0
- 在LLVM中如何判断二个基本块(Basic Block)的支配关系
- 在LLVM控制流图(CFG)中如何获得某个块(Block)的前继块和后继块
- llvm中如何利用分支概率和基本块频率估计
- 使用Intel编译器(0)基础(2)基本块Basic Block
- LLVM基本块频率术语
- LLVM 的后序支配树(Post Dominator Tree)使用方法
- 在流程图中求支配点的一种快速算法
- iOS中使用block块的用法
- iOS中Block代码块的使用
- OC中块Block的用法
- LLVM教程(二)-- LLVM的安装
- LLVM--如何在代码中调用遍(Pass)
- 如何在一个事务中插入一对多关系的多个EO对象?
- 如何在eclipse中开发多个聚合关系的maven项目并用git管理
- IOS中块Block
- OpenGL 如何判断点在多边形的内外关系
- magento中如何调用static block(静态块)
- magento2 如何在phtml中调用另一个block的template
- ECM: The inventory location file for the special Windows NT case does not exist or is unreadable
- 视频 裁剪 合并 ios
- tomcat startup启动内存溢出
- 东风公司符合公司的风华绝代实践活动上市公司我给热带风光
- android驱动例子(LED灯控制)
- 在LLVM中如何判断二个基本块(Basic Block)的支配关系
- KindEditor 编辑器 获取 textarea 里的数据
- ORACLE 创建视图时,提示用户权限不足
- 保存图片/视频到相册 保存完成后通知事件 IOS
- 最长公共子序列(LCS)问题
- 好文章收集
- Srtuts2学习笔记--批量类型转换
- 支持在 Web 浏览器中使用加密媒体扩展和 Microsoft PlayReady DRM
- android中的style部分属性值介绍