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?
相关问题
- CMakeList file to generate LLVM bitcode file from
- LLVM OPT not giving optimised file as output.
- How readily do unterminated char arrays in C++?
- Python numba / llvmlite on Debian 8 - i can't
- llvm::DIInstruction getFilename returns filename w
相关文章
- Writing a stream protocol: Message size field or M
- How to clone or create an AST Stmt node of clang?
- Libclang API to get function definitions defined i
- No format security warnings in Xcode 4.4
- LLVM retrieve name of AllocaInst
- In LLVM IR, I want to copy a set of Instructions a
- compiling with clang and plugin
- How to get the filename and directory from a LLVM
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.
Take a look at
llvm::ReplaceInstWithInst
in BasicBlockUtils.h for a convenient way to replace one instruction with another.