• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -instcombine -S -o - %s | FileCheck %s
2
3; CHECK-NOT: getelementptr
4; CHECK-NOT: ptrtoint
5; CHECK: bitcast i8*
6%struct.S = type { i32 (...)** }
7
8@_ZL1p = internal constant { i64, i64 } { i64 1, i64 0 }, align 8
9
10define void @_Z1g1S(%struct.S* %s) nounwind {
11entry:
12  %tmp = load { i64, i64 }* @_ZL1p, align 8
13  %memptr.adj = extractvalue { i64, i64 } %tmp, 1
14  %0 = bitcast %struct.S* %s to i8*
15  %1 = getelementptr inbounds i8* %0, i64 %memptr.adj
16  %this.adjusted = bitcast i8* %1 to %struct.S*
17  %memptr.ptr = extractvalue { i64, i64 } %tmp, 0
18  %2 = and i64 %memptr.ptr, 1
19  %memptr.isvirtual = icmp ne i64 %2, 0
20  br i1 %memptr.isvirtual, label %memptr.virtual, label %memptr.nonvirtual
21
22memptr.virtual:                                   ; preds = %entry
23  %3 = bitcast %struct.S* %this.adjusted to i8**
24  %memptr.vtable = load i8** %3
25  %4 = sub i64 %memptr.ptr, 1
26  %5 = getelementptr i8* %memptr.vtable, i64 %4
27  %6 = bitcast i8* %5 to void (%struct.S*)**
28  %memptr.virtualfn = load void (%struct.S*)** %6
29  br label %memptr.end
30
31memptr.nonvirtual:                                ; preds = %entry
32  %memptr.nonvirtualfn = inttoptr i64 %memptr.ptr to void (%struct.S*)*
33  br label %memptr.end
34
35memptr.end:                                       ; preds = %memptr.nonvirtual, %memptr.virtual
36  %7 = phi void (%struct.S*)* [ %memptr.virtualfn, %memptr.virtual ], [ %memptr.nonvirtualfn, %memptr.nonvirtual ]
37  call void %7(%struct.S* %this.adjusted)
38  ret void
39}
40