Hi, Is it somehow possible to have LLVM emit machine code for the 'unreachable' IR instruction, which would assert that it indeed never gets reached? Vadim -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140414/02108a74/attachment.html>
Hello x86 backend emits ud2 instruction in this case On Mon, Apr 14, 2014 at 1:46 PM, Vadim Chugunov <vadimcn at gmail.com> wrote:> Hi, > Is it somehow possible to have LLVM emit machine code for the 'unreachable' > IR instruction, which would assert that it indeed never gets reached? > > Vadim > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University
On Mon, Apr 14, 2014 at 2:46 AM, Vadim Chugunov <vadimcn at gmail.com> wrote:> Hi, > Is it somehow possible to have LLVM emit machine code for the 'unreachable' > IR instruction, which would assert that it indeed never gets reached?Take a look at LLVM's implementation of an "llvm_unreachable" macro to see how the LLVM project does this. Essentially lllvm's unreachable IR instruction is /not/ an assert or check, it's a compiler hint. So at -O0, LLVM's llvm_unreachable compiles to a check/assert, at higher optimization levels it compiles to an intrinsic that is lowered to an unreachable IR instruction and is used to assist optimization. - David
I am not seeing this happening, at least not for unreachables that follow calls to 'noreturn' functions. On Apr 14, 2014, at 3:48 AM, Anton Korobeynikov <anton at korobeynikov.info> wrote:> Hello > > x86 backend emits ud2 instruction in this case > > On Mon, Apr 14, 2014 at 1:46 PM, Vadim Chugunov <vadimcn at gmail.com> wrote: >> Hi, >> Is it somehow possible to have LLVM emit machine code for the 'unreachable' >> IR instruction, which would assert that it indeed never gets reached? >> >> Vadim >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State University
Maybe Matching Threads
- [LLVMdev] Emit code for 'unreachable'
- [LLVMdev] [lldb-dev] RFC: LLVM should require a working C++11 <thread>, <mutex>, and <atomic>
- [LLVMdev] Argument Lowering Redux
- [LLVMdev] Finding previous emitted instruction
- [LLVMdev] [lldb-dev] RFC: LLVM should require a working C++11 <thread>, <mutex>, and <atomic>