return after trap

Jonas Paulsson via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 8 04:23:09 PDT 2017


Hi,

SystemZ has some failing tests relating to llvm.trap (with 
EXPENSIVE_CHECKS).  See https://bugs.llvm.org/show_bug.cgi?id=33047.

One of the problems is that this function

*** 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 (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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170608/f9ebe1bc/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: visitRet_TRAP.patch
Type: text/x-patch
Size: 596 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170608/f9ebe1bc/attachment.bin>


More information about the llvm-commits mailing list