Home | History | Annotate | Download | only in WholeProgramDevirt
      1 ; RUN: opt -S -wholeprogramdevirt %s | FileCheck %s
      2 
      3 target datalayout = "e-p:64:64"
      4 target triple = "x86_64-unknown-linux-gnu"
      5 
      6 @vt1 = constant [1 x i8*] [i8* bitcast (i32 (i8*)* @vf1 to i8*)], !type !0
      7 @vt2 = constant [1 x i8*] [i8* bitcast (i32 (i8*)* @vf2 to i8*)], !type !0
      8 
      9 define i32 @vf1(i8* %this) readnone {
     10   ret i32 123
     11 }
     12 
     13 define i32 @vf2(i8* %this) readnone {
     14   ret i32 123
     15 }
     16 
     17 ; CHECK: define i32 @call
     18 define i32 @call(i8* %obj) personality i8* undef {
     19   %vtableptr = bitcast i8* %obj to [1 x i8*]**
     20   %vtable = load [1 x i8*]*, [1 x i8*]** %vtableptr
     21   %vtablei8 = bitcast [1 x i8*]* %vtable to i8*
     22   %p = call i1 @llvm.type.test(i8* %vtablei8, metadata !"typeid")
     23   call void @llvm.assume(i1 %p)
     24   %fptrptr = getelementptr [1 x i8*], [1 x i8*]* %vtable, i32 0, i32 0
     25   %fptr = load i8*, i8** %fptrptr
     26   %fptr_casted = bitcast i8* %fptr to i32 (i8*)*
     27   ; CHECK: br label %[[RET:[0-9A-Za-z]*]]
     28   %result = invoke i32 %fptr_casted(i8* %obj) to label %ret unwind label %unwind
     29 
     30 unwind:
     31   %x = landingpad i32 cleanup
     32   unreachable
     33 
     34 ret:
     35   ; CHECK: [[RET]]:
     36   ; CHECK-NEXT: ret i32 123
     37   ret i32 %result
     38 }
     39 
     40 declare i1 @llvm.type.test(i8*, metadata)
     41 declare void @llvm.assume(i1)
     42 
     43 !0 = !{i32 0, !"typeid"}
     44