Home | History | Annotate | Download | only in Inline
      1 ; RUN: opt < %s -inline -argpromotion -instcombine -disable-output
      2 
      3 ; This test was failing because the inliner would inline @list_DeleteElement
      4 ; into @list_DeleteDuplicates and then into @inf_GetBackwardPartnerLits,
      5 ; turning the indirect call into a direct one.  This allowed instcombine to see
      6 ; the bitcast and eliminate it, deleting the original call and introducing
      7 ; another one.  This crashed the inliner because the new call was not in the
      8 ; callgraph.
      9 
     10 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
     11 target triple = "i386-apple-darwin10.0"
     12 
     13 
     14 define void @list_DeleteElement(i32 (i8*, i8*)* nocapture %Test) nounwind ssp {
     15 entry:
     16   %0 = call i32 %Test(i8* null, i8* undef) nounwind
     17   ret void
     18 }
     19 
     20 
     21 define void @list_DeleteDuplicates(i32 (i8*, i8*)* nocapture %Test) nounwind ssp {
     22 foo:
     23   call void @list_DeleteElement(i32 (i8*, i8*)* %Test) nounwind ssp 
     24   call fastcc void @list_Rplacd1284() nounwind ssp
     25   unreachable
     26 
     27 }
     28 
     29 define internal i32 @inf_LiteralsHaveSameSubtermAndAreFromSameClause(i32* nocapture %L1, i32* nocapture %L2) nounwind readonly ssp {
     30 entry:
     31   unreachable
     32 }
     33 
     34 
     35 define internal fastcc void @inf_GetBackwardPartnerLits(i32* nocapture %Flags) nounwind ssp {
     36 test:
     37   call void @list_DeleteDuplicates(i32 (i8*, i8*)* bitcast (i32 (i32*, i32*)* @inf_LiteralsHaveSameSubtermAndAreFromSameClause to i32 (i8*, i8*)*)) nounwind 
     38   ret void
     39 }
     40 
     41 
     42 define void @inf_BackwardEmptySortPlusPlus() nounwind ssp {
     43 entry:
     44   call fastcc void @inf_GetBackwardPartnerLits(i32* null) nounwind ssp
     45   unreachable
     46 }
     47 
     48 define void @inf_BackwardWeakening() nounwind ssp {
     49 entry:
     50   call fastcc void @inf_GetBackwardPartnerLits(i32* null) nounwind ssp
     51   unreachable
     52 }
     53 
     54 declare fastcc void @list_Rplacd1284() nounwind ssp
     55 
     56 
     57 
     58 
     59 ;============================
     60 ; PR5208
     61 
     62 define void @AAA() personality i32 (...)* @__gxx_personality_v0 {
     63 entry:
     64   %A = alloca i8, i32 undef, align 1
     65   invoke fastcc void @XXX()
     66           to label %invcont98 unwind label %lpad156 
     67 
     68 invcont98:                          
     69   unreachable
     70 
     71 lpad156:                            
     72   %exn = landingpad {i8*, i32}
     73             cleanup
     74   unreachable
     75 }
     76 
     77 declare i32 @__gxx_personality_v0(...)
     78 
     79 declare fastcc void @YYY()
     80 
     81 define internal fastcc void @XXX() personality i32 (...)* @__gxx_personality_v0 {
     82 entry:
     83   %B = alloca i8, i32 undef, align 1
     84   invoke fastcc void @YYY()
     85           to label %bb260 unwind label %lpad
     86 
     87 bb260:                              
     88   ret void
     89 
     90 lpad:                               
     91   %exn = landingpad {i8*, i32}
     92             cleanup
     93   resume { i8*, i32 } %exn
     94 }
     95 
     96 
     97 
     98 ;; This exposed a crash handling devirtualized calls.
     99 define void @f1(void ()* %f) ssp {
    100 entry:
    101   call void %f()
    102   ret void
    103 }
    104 
    105 define void @f4(i32 %size) ssp personality i32 (...)* @__gxx_personality_v0 {
    106 entry:
    107   invoke void @f1(void ()* @f3)
    108           to label %invcont3 unwind label %lpad18
    109 
    110 invcont3:                                         ; preds = %bb1
    111   ret void
    112 
    113 lpad18:                                           ; preds = %invcont3, %bb1
    114   %exn = landingpad {i8*, i32}
    115             cleanup
    116   unreachable
    117 }
    118 
    119 define void @f3() ssp {
    120 entry:
    121   unreachable
    122 }
    123 
    124 declare void @f5() ssp
    125 
    126 
    127 
    128