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
I've looked through LLVM codegen code and found that SelectionDAGBuilder::visitUnreachable() is basically a no-op. So I don't see how it could have generated anything... What would be the right way to go about adding this functionality? Right now I am thinking to add 'EmitTargetCodeForUnreachable()' method to TargetSelectionDAGInfo class, so that targets can emit code for 'unreachable', if they need that. Does that sound right? Vadim On Mon, Apr 14, 2014 at 1:53 PM, Vadim <vadimcn at gmail.com> wrote:> 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 >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140415/84533dfa/attachment.html>
On Tue, Apr 15, 2014 at 2:14 PM, Vadim Chugunov <vadimcn at gmail.com> wrote:> I've looked through LLVM codegen code and found that > SelectionDAGBuilder::visitUnreachable() is basically a no-op. So I don't > see how it could have generated anything... > > What would be the right way to go about adding this functionality? > Right now I am thinking to add 'EmitTargetCodeForUnreachable()' method to > TargetSelectionDAGInfo class, so that targets can emit code for > 'unreachable', if they need that. Does that sound right? >Personally I'm in favor, but others may disagree. Right now clang inserts calls to llvm.trap(), and that's how we get ud2's when falling off the end of a function with a return type. That may be the preferred approach for __builtin_unreachable(), since other clients of LLVM at -O0 may actually want it to produce code quickly without inserting any debugging aids. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140415/57546086/attachment.html>