<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hi,</p>
    <p>SystemZ has some failing tests relating to llvm.trap (with
      EXPENSIVE_CHECKS).  See
      <a class="moz-txt-link-freetext" href="https://bugs.llvm.org/show_bug.cgi?id=33047">https://bugs.llvm.org/show_bug.cgi?id=33047</a>.</p>
    <p>One of the problems is that this function<br>
    </p>
    <pre class="bz_comment_text" id="comment_text_1">*** IR Dump After Module Verifier ***
define i32 @f0() {
entry:
  tail call void @llvm.trap()
  ret i32 0
}

never reaches the ret, but still SystemZTargetLowering::LowerReturn() is called. This results in

BB#0: derived from LLVM BB %entry
        Trap
        %vreg0<def> = LHI 0; GR32Bit:%vreg0
        %R2L<def> = COPY %vreg0; GR32Bit:%vreg0
        Return %R2L<imp-use>

, and this fails since Trap is a terminator (<tt><font size="2">non-terminator after terminator instruction).

It seems that the call to LowerReturn() should never have been made, since it is unreachable.

The attached patch fixes this particular case. Is this good enough, or is there something more
general needed, like a general treatment of no-return intrinsics? (no-return functions should
also never get a return instruction).

These are tests that fail outside CodeGen/SystemZ with this patch:

    LLVM :: CodeGen/Generic/llc-start-stop.ll
    LLVM :: CodeGen/Generic/print-machineinstrs.ll
    LLVM :: CodeGen/X86/x86-framelowering-trap.ll

/Jonas

</font></tt></pre>
  </body>
</html>