File: devirt.ll

package info (click to toggle)
llvm-3.0 3.0-10
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 75,412 kB
  • sloc: cpp: 468,043; asm: 109,345; ansic: 13,782; sh: 12,935; ml: 4,716; python: 4,351; perl: 2,096; makefile: 1,905; pascal: 1,578; exp: 389; xml: 283; lisp: 187; csh: 117
file content (39 lines) | stat: -rw-r--r-- 1,477 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
; RUN: opt -instcombine -S -o - %s | FileCheck %s

; CHECK-NOT: getelementptr
; CHECK-NOT: ptrtoint
; CHECK: bitcast i8*
%struct.S = type { i32 (...)** }

@_ZL1p = internal constant { i64, i64 } { i64 1, i64 0 }, align 8

define void @_Z1g1S(%struct.S* %s) nounwind {
entry:
  %tmp = load { i64, i64 }* @_ZL1p, align 8
  %memptr.adj = extractvalue { i64, i64 } %tmp, 1
  %0 = bitcast %struct.S* %s to i8*
  %1 = getelementptr inbounds i8* %0, i64 %memptr.adj
  %this.adjusted = bitcast i8* %1 to %struct.S*
  %memptr.ptr = extractvalue { i64, i64 } %tmp, 0
  %2 = and i64 %memptr.ptr, 1
  %memptr.isvirtual = icmp ne i64 %2, 0
  br i1 %memptr.isvirtual, label %memptr.virtual, label %memptr.nonvirtual

memptr.virtual:                                   ; preds = %entry
  %3 = bitcast %struct.S* %this.adjusted to i8**
  %memptr.vtable = load i8** %3
  %4 = sub i64 %memptr.ptr, 1
  %5 = getelementptr i8* %memptr.vtable, i64 %4
  %6 = bitcast i8* %5 to void (%struct.S*)**
  %memptr.virtualfn = load void (%struct.S*)** %6
  br label %memptr.end

memptr.nonvirtual:                                ; preds = %entry
  %memptr.nonvirtualfn = inttoptr i64 %memptr.ptr to void (%struct.S*)*
  br label %memptr.end

memptr.end:                                       ; preds = %memptr.nonvirtual, %memptr.virtual
  %7 = phi void (%struct.S*)* [ %memptr.virtualfn, %memptr.virtual ], [ %memptr.nonvirtualfn, %memptr.nonvirtual ]
  call void %7(%struct.S* %this.adjusted)
  ret void
}