Home | History | Annotate | Download | only in X86
      1 ; Check that eh_return & unwind_init were properly lowered
      2 ; RUN: llc < %s -verify-machineinstrs | FileCheck %s
      3 
      4 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
      5 target triple = "x86_64-unknown-linux-gnu"
      6 
      7 ; CHECK: test
      8 ; CHECK: pushq %rbp
      9 ; CHECK: movq %rsp, %rbp
     10 ; CHECK: popq %rbp
     11 ; CHECK: movq %rcx, %rsp
     12 ; CHECK: retq # eh_return, addr: %rcx
     13 define i8* @test(i64 %a, i8* %b)  {
     14 entry:
     15   call void @llvm.eh.unwind.init()
     16   %foo   = alloca i32
     17   call void @llvm.eh.return.i64(i64 %a, i8* %b)
     18   unreachable
     19 }
     20 
     21 declare void @llvm.eh.return.i64(i64, i8*)
     22 declare void @llvm.eh.unwind.init()
     23 
     24 @b = common global i32 0, align 4
     25 @a = common global i32 0, align 4
     26 
     27 ; PR14750
     28 ; This function contains a normal return as well as eh_return.
     29 ; CHECK: _Unwind_Resume_or_Rethrow
     30 define i32 @_Unwind_Resume_or_Rethrow() nounwind uwtable ssp {
     31 entry:
     32   %0 = load i32, i32* @b, align 4
     33   %tobool = icmp eq i32 %0, 0
     34   br i1 %tobool, label %if.end, label %if.then
     35 
     36 if.then:                                          ; preds = %entry
     37   ret i32 0
     38 
     39 if.end:                                           ; preds = %entry
     40   %call = tail call i32 (...) @_Unwind_ForcedUnwind_Phase2() nounwind
     41   store i32 %call, i32* @a, align 4
     42   %tobool1 = icmp eq i32 %call, 0
     43   br i1 %tobool1, label %cond.end, label %cond.true
     44 
     45 cond.true:                                        ; preds = %if.end
     46   tail call void @abort() noreturn nounwind
     47   unreachable
     48 
     49 cond.end:                                         ; preds = %if.end
     50   tail call void @llvm.eh.return.i64(i64 0, i8* null)
     51   unreachable
     52 }
     53 
     54 declare i32 @_Unwind_ForcedUnwind_Phase2(...)
     55 declare void @abort() noreturn
     56