如何在LLVM 3.5中遍历支配者树
How to traverse the dominator tree in LLVM 3.5?
有人知道如何遍历LLVM 3.5中的支配者树吗?我可以使用DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>(F).getDomTree();
检索DOM树。然而,我不确定我该如何穿越它。有什么想法吗?
这里的"遍历"是什么意思?DominatorTree
具有有用的调用,如dominates
、getDescendants
和isReachableFromEntry
。请注意,它也是从DominatorTreeBase
派生的,因此您可能需要检查此类提供的方法。
LLVM本身中有大量使用DominatorTree
的示例。
如果您只想按深度优先顺序遍历一个支配树,您可以尝试:
for (auto node = GraphTraits<DominatorTree *>::nodes_begin(DT);
node != GraphTraits<DominatorTree *>::nodes_end(DT); ++node) {
BasicBlock *BB = node->getBlock();
// whatever you want to do with BB
}
此代码片段摘自StraightLineStrengthReduce。
相关文章:
- 有什么方法可以遍历结构吗
- 在循环中按顺序遍历成员变量
- 遍历模板参数
- 在遍历处理程序的向量时注册和注销处理程序
- C++RapidXml-使用first_node()遍历以修改XML文件中节点的值
- 遍历并行数组以确定C++中的最大数字
- 遍历顺序由 std::文件系统directory_iterator给出
- 遍历链表时的无限循环
- 遍历unordered_map向量
- 从预序遍历构造 bst 的 c++ 和 python 解决方案之间的区别
- C++声明双链表,使用两个 for 循环双向遍历列表并打印
- 如何正确地推回然后遍历堆中对象的向量?
- 遍历二维数组的所有子数组
- 如何在可变参数模板函数中遍历可变参数元组?
- 避免在遍历 IShellItemArray 时出现代码重复
- 从特定键开始遍历地图
- 关于链表遍历和调试的困惑
- 将树节点添加到向量向量中的 n 元树遍历的平均和最坏情况时间复杂度是多少?
- 为什么即使使用 for 循环遍历我的向量,它也没有输出到控制台?(C++)
- 如何在LLVM 3.5中遍历支配者树