点击查看代码
//遍历一个function
func.walk([&](Operation *op) {
size_t nUser =
llvm::count_if(op->getUsers(), [](auto *) { return true; });
unresolvedUsers[op] = nUser;
});
//返乡遍历operand
for (auto opr : llvm::reverse(op->getOperands())) {
if (auto def = opr.getDefiningOp<StcGoatInterface>()) {
if (--unresolvedUsers[def] == 0) {
todoList.push_front(def);
}
}
}
//OpBuilder使用Context初始化:
OpBuilder builder(op->getContext());