LLVM 中的实时值
假设我的 CFG(以及其他)中有两个基本块 A 和 B,其边缘从 A 到 B。我需要执行以下操作:
- 获取实时值的集合 S 该边缘(它可以是 过度近似,即可能 包含非实时值 不再)
- 将它们每个映射到另一个 值 (S->S')
- 替换 B 及其中的 - 继任者 - 价值观的所有用途 在 S 中使用映射值 (S')
LLVM 是否提供了一种简单的方法来完成第一点和第三点(因为我似乎无法找到它)?如果没有,您对如何做有什么建议吗?
注意:交叉发布在 LLVM 邮件列表上
Suppose I have in my CFG (among others) two basic blocks A and B, with an edge from A to B. I need to do the following:
- get the set S of live values across
that edge (it can be an
overapproximation, i.e. it might
contain values that are not live
anymore) - map each of them to another
value (S->S') - replace - in B and its
successors - all the uses of values
in S with the mapped values (S')
Does LLVM provide an easy way to do the first and third points (because I can't seem to be able to find it)? If not, do you have any suggestions about how to do it?
note: crossposted on the LLVM mailing list
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对你的问题没有明确的答案,但我想到了要遵循的导演。我希望它能以某种方式帮助你。
首先,我会查看 “迭代 BasicBlock 中的指令” 和 来自 LLVM 程序员的“迭代 def-use 和 use-def 链”手册。它给出了如何迭代基本块中的指令以及该值的用户的想法。
由于您需要了解边缘的实时值,因此我会查看 “迭代函数中的 BasicBlocks ",并尝试确定用户(在您迭代的范围内)的放置位置,例如使用 const BasicBlock* llvm::Instruction::getParent()const。
如果用户所处位置的信息不够,您可能想利用[支配者和后支配者分析],请查看:
这可能会帮助你确定块或指令之间的主导关系,这可能有助于您创建集合。
I do not have clear answer to your question, but director to follow, that came to my mind. I hope it will help you in some way.
First, I would check out "Iterating over the Instructions in a BasicBlock" and "Iterating over def-use & use-def chains" from LLVM Programmers Manual. It gives an idea how to iterate over instructions in basic block and users of this value.
As you need to know living values across the edge, I would check out "Iterating over the BasicBlocks in a Function", and try to determine where users (over ech you iterate) are placed, for example with const BasicBlock* llvm::Instruction::getParent()const.
If information, where users are placed is not enough, you might like to take advantage of [dominators and postdominators analysis], check out :
This might help you determine dominance relation between blocks or instructions, what might help you with creation of your sets.