Home | History | Annotate | Download | only in X86
      1 ; RUN: llc < %s -mtriple=x86_64-pc-win32 | FileCheck %s
      2 
      3 %struct.A = type { i8 }
      4 %struct.B = type { i32 }
      5 %struct.C = type { %struct.B }
      6 %struct.D = type { %struct.B }
      7 %struct.E = type { %struct.B }
      8 
      9 declare %struct.A* @A_ctor(%struct.A* returned)
     10 declare %struct.B* @B_ctor(%struct.B* returned, i32)
     11 
     12 declare %struct.A* @A_ctor_nothisret(%struct.A*)
     13 declare %struct.B* @B_ctor_nothisret(%struct.B*, i32)
     14 
     15 define %struct.C* @C_ctor(%struct.C* %this, i32 %y) {
     16 entry:
     17 ; CHECK-LABEL: C_ctor:
     18 ; CHECK: jmp     B_ctor                  # TAILCALL
     19   %0 = getelementptr inbounds %struct.C, %struct.C* %this, i64 0, i32 0
     20   %call = tail call %struct.B* @B_ctor(%struct.B* %0, i32 %y)
     21   ret %struct.C* %this
     22 }
     23 
     24 define %struct.C* @C_ctor_nothisret(%struct.C* %this, i32 %y) {
     25 entry:
     26 ; CHECK-LABEL: C_ctor_nothisret:
     27 ; CHECK-NOT: jmp     B_ctor_nothisret
     28   %0 = getelementptr inbounds %struct.C, %struct.C* %this, i64 0, i32 0
     29   %call = tail call %struct.B* @B_ctor_nothisret(%struct.B* %0, i32 %y)
     30   ret %struct.C* %this
     31 }
     32 
     33 define %struct.D* @D_ctor(%struct.D* %this, i32 %y) {
     34 entry:
     35 ; CHECK-LABEL: D_ctor:
     36 ; CHECK: movq    %rcx, [[SAVETHIS:%r[0-9a-z]+]]
     37 ; CHECK: callq   A_ctor
     38 ; CHECK: movq    [[SAVETHIS]], %rcx
     39 ; CHECK: jmp     B_ctor                  # TAILCALL
     40   %0 = bitcast %struct.D* %this to %struct.A*
     41   %call = tail call %struct.A* @A_ctor(%struct.A* %0)
     42   %1 = getelementptr inbounds %struct.D, %struct.D* %this, i64 0, i32 0
     43   %call2 = tail call %struct.B* @B_ctor(%struct.B* %1, i32 %y)
     44 ; (this next line would never be generated by Clang, actually)
     45   %2 = bitcast %struct.A* %call to %struct.D*
     46   ret %struct.D* %2
     47 }
     48 
     49 define %struct.D* @D_ctor_nothisret(%struct.D* %this, i32 %y) {
     50 entry:
     51 ; CHECK-LABEL: D_ctor_nothisret:
     52 ; CHECK: movq    %rcx, [[SAVETHIS:%r[0-9a-z]+]]
     53 ; CHECK: callq   A_ctor_nothisret
     54 ; CHECK: movq    [[SAVETHIS]], %rcx
     55 ; CHECK-NOT: jmp     B_ctor_nothisret
     56   %0 = bitcast %struct.D* %this to %struct.A*
     57   %call = tail call %struct.A* @A_ctor_nothisret(%struct.A* %0)
     58   %1 = getelementptr inbounds %struct.D, %struct.D* %this, i64 0, i32 0
     59   %call2 = tail call %struct.B* @B_ctor_nothisret(%struct.B* %1, i32 %y)
     60 ; (this next line would never be generated by Clang, actually)
     61   %2 = bitcast %struct.A* %call to %struct.D*
     62   ret %struct.D* %2
     63 }
     64 
     65 define %struct.E* @E_ctor(%struct.E* %this, i32 %x) {
     66 entry:
     67 ; CHECK-LABEL: E_ctor:
     68 ; CHECK: movq    %rcx, [[SAVETHIS:%r[0-9a-z]+]]
     69 ; CHECK: callq   B_ctor
     70 ; CHECK: movq    [[SAVETHIS]], %rcx
     71 ; CHECK: jmp     B_ctor                  # TAILCALL
     72   %b = getelementptr inbounds %struct.E, %struct.E* %this, i64 0, i32 0
     73   %call = tail call %struct.B* @B_ctor(%struct.B* %b, i32 %x)
     74   %call4 = tail call %struct.B* @B_ctor(%struct.B* %b, i32 %x)
     75   ret %struct.E* %this
     76 }
     77 
     78 define %struct.E* @E_ctor_nothisret(%struct.E* %this, i32 %x) {
     79 entry:
     80 ; CHECK-LABEL: E_ctor_nothisret:
     81 ; CHECK: movq    %rcx, [[SAVETHIS:%r[0-9a-z]+]]
     82 ; CHECK: callq   B_ctor_nothisret
     83 ; CHECK: movq    [[SAVETHIS]], %rcx
     84 ; CHECK-NOT: jmp     B_ctor_nothisret
     85   %b = getelementptr inbounds %struct.E, %struct.E* %this, i64 0, i32 0
     86   %call = tail call %struct.B* @B_ctor_nothisret(%struct.B* %b, i32 %x)
     87   %call4 = tail call %struct.B* @B_ctor_nothisret(%struct.B* %b, i32 %x)
     88   ret %struct.E* %this
     89 }
     90