编译器架构的LLVM IR 5st Day(分解struct)

llvm instruction use 的用法

    Instruction *instr = WorkListLoad->pop_back_val();
    for (Value::user_iterator UI = instr->user_begin(), E = instr->user_end(); UI!= E; ++UI) {
      User *U = *UI;
      assert (isa<Instruction> (U));
      Instruction* CI = dyn_cast<Instruction> (U);
      assert(CI->getOpcode() == llvm::Instruction::GetElementPtr);
      if (CI->getNumOperands() >= 3) {
        llvm::Value* val_op = CI->getOperand(0);
        llvm::Value* val_op_2 = CI->getOperand(2);
        string variable_name = getLabel(val_op_2);
        outs() << "variable name " << variable_name << "\n";
        if (alloca_keymap_.count(variable_name) > 0) {
          Value* new_var = alloca_keymap_[variable_name];
          vector<Value *> IdxList = valueInstr(CI);
          ArrayRef<Value*> list(IdxList);
          GetElementPtrInst* ptrInst_new = GetElementPtrInst::CreateInBounds(
              dyn_cast<PointerType> (new_var->getType())->getElementType(),
              new_var, list, "");
          ReplaceInstWithInst(CI, ptrInst_new);
        }
      }
    }
  }
上一篇:PyQt5基础学习-QTreeWidget().clicked.connect(为树控件添加响应事件) 1.QTreeWidget().currentItem(获得当前点击的树控件)


下一篇:PyQt5基础学习-QTreeWidget(树控件) 1.QTreeWidget().setColumnCount(设置列数) 2.QTreeWidget().setHeaderLabels(设置列标