Llvm删除终结者指令 [英] Llvm Remove Terminator Instruction

查看:247
本文介绍了Llvm删除终结者指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想删除一个UnreachableInst,因为以前的转换使其可以访问.但是,由于UnreachableInst是其BasicBlock的终结器,因此调用deleteFromParent()会给我带来格式错误的BasicBlock.如何修复BasicBlock,使其在UnreachableInst之前的指令处终止?

I want to remove an UnreachableInst since a previous transformation has made it reachable. However, calling eraseFromParent() gives me a malformed BasicBlock since the UnreachableInst is the terminator of its BasicBlock. How do I fix the BasicBlock to terminate at the instruction previous to the UnreachableInst?

推荐答案

每个基本块都必须以终结符结尾.我认为,删除不可达指令的最直接方法就是用另一个终止符替换,例如,跳转到下一个基本块,返回指令等.

Every basic block must end with a terminator. I think that the most straightforward way to remove the unreachable instruction, then, is to replace it with another terminator - for example, a branch into the next basic block, a return instruction, etc.

在BasicBlockUtils.h中查看llvm::ReplaceInstWithInst,这是一种将一条指令替换为另一条指令的便捷方法.

Take a look at llvm::ReplaceInstWithInst in BasicBlockUtils.h for a convenient way to replace one instruction with another.

这篇关于Llvm删除终结者指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆