美文网首页LLVM
LLVM中Def-Use获取

LLVM中Def-Use获取

作者: HaoMengHIT | 来源:发表于2019-03-15 17:54 被阅读0次

Frequently, we might have an instance of the Value Class and we want to determine which Users use the Value. The list of all Users of a particular Value is called a def-use chain.

1. 函数的def-use

Function *F = ...;
 
for (User *U : F->users()) {
  if (Instruction *Inst = dyn_cast<Instruction>(U)) {
    errs() << "F is used in instruction:\n";
    errs() << *Inst << "\n";
  }

或者

Function *F = ...;
for (Value::use_iterator U = F->use_begin(), e = F->use_end(); U != e; ++U) {
  if (Instruction *Inst = dyn_cast<Instruction>(&*(U->getUser()))) {
    errs() << "F is used in instruction:\n";
    errs() << *Inst << "\n";
}

2. 指令的Def-Use

Instruction *A = ...;
 
for (User *U : A->users()) {
  if (Instruction *Inst = dyn_cast<Instruction>(U)) {
    errs() << "A is used in instruction:\n";
    errs() << *Inst << "\n";
  }

Instruction *A = ...;
for (Value::use_iterator i = A->use_begin(), e = A->use_end(); i != e; ++i) {
  if (Instruction *U = dyn_cast<Instruction>(&*(i->getUser()))) {
  ...
  }
}

相关文章

  • LLVM中Def-Use获取

    Frequently, we might have an instance of the Value Class ...

  • 浅谈LLVM

    何为LLVM 在LLVM的官网(https://llvm.org/[https://llvm.org/])中写到T...

  • Xcode集成O-LLVM

    获取O-LLVM源码 要在Xcode中使用O-LLVM,必须要编写一个Xcode插件。 首先 更改 不懂vim操作...

  • 【LLVM】编写自己的pass

    【LLVM】编写自己的pass LLVM的Pass框架是LLVM中的重要部分,多个pass一起完成了LLVM的优化...

  • OCLint 获取源代码 准备工作 LLVM System Requirements Python Git Apa...

  • LLVM基础(IR简介&CFG图生成&可视化)

    LLVM IR LLVM 提供了一个详细的汇编语言表示(参阅 参考资料 获取相关的链接)。在开始编写我们之前讨论的...

  • llvm编译环境配置

    方式一 1、获取源代码 git clone --depth 1 https://github.com/llvm/l...

  • Compiler-RT 7.0.1 功能简介

    ☞ LLVM 7.0.1 LLVM中的Compiler-RT相当于GCC中的libgcc,为目标平台提供其硬件不支...

  • LLVM

    LLVM 什么是LLVM? 官网:https://llvm.org/ The LLVM Project is a ...

  • iOS_LLVM

    LLVM 官网:https://llvm.org/[https://llvm.org/] The LLVM Pro...

网友评论

    本文标题:LLVM中Def-Use获取

    本文链接:https://www.haomeiwen.com/subject/cgprmqtx.html