1 ; REQUIRES: x86-registered-target
3 ; Test index-based devirtualization when one copy is an alias.
5 ; Generate unsplit module with summary for ThinLTO index-based WPD.
6 ; RUN: opt -thinlto-bc -o %t3.o %s
7 ; RUN: opt -thinlto-bc -o %t4.o %p/Inputs/devirt_alias.ll
9 ; RUN: llvm-lto2 run %t3.o %t4.o -save-temps -pass-remarks=. \
10 ; RUN: -wholeprogramdevirt-print-index-based \
12 ; RUN: -r=%t3.o,test,px \
13 ; RUN: -r=%t3.o,_ZTV1D, \
14 ; RUN: -r=%t3.o,_ZN1D1mEi, \
15 ; RUN: -r=%t4.o,_ZN1D1mEi,p \
16 ; RUN: -r=%t4.o,_ZTV1D,px \
17 ; RUN: -r=%t4.o,some_name,px \
18 ; RUN: 2>&1 | FileCheck %s --check-prefix=REMARK --check-prefix=PRINT
19 ; RUN: llvm-dis %t5.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR1
21 ; PRINT-DAG: Devirtualized call to {{.*}} (_ZN1D1mEi)
23 ; REMARK-DAG: single-impl: devirtualized a call to _ZN1D1mEi
25 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
26 target triple = "x86_64-grtev4-linux-gnu"
28 %struct.D = type { i32 (...)** }
30 @_ZTV1D = linkonce_odr constant { [3 x i8*] } { [3 x i8*] [i8* null, i8* undef, i8* bitcast (i32 (%struct.D*, i32)* @_ZN1D1mEi to i8*)] }, !type !3
32 ; CHECK-IR1-LABEL: define i32 @test
33 define i32 @test(%struct.D* %obj2, i32 %a) {
35 %0 = bitcast %struct.D* %obj2 to i8***
36 %vtable2 = load i8**, i8*** %0
37 %1 = bitcast i8** %vtable2 to i8*
38 %p2 = call i1 @llvm.type.test(i8* %1, metadata !"_ZTS1D")
39 call void @llvm.assume(i1 %p2)
41 %2 = bitcast i8** %vtable2 to i32 (%struct.D*, i32)**
42 %fptr33 = load i32 (%struct.D*, i32)*, i32 (%struct.D*, i32)** %2, align 8
44 ; Check that the call was devirtualized.
45 ; CHECK-IR1: %call4 = tail call i32 @_ZN1D1mEi
46 %call4 = tail call i32 %fptr33(%struct.D* nonnull %obj2, i32 %a)
49 ; CHECK-IR1-LABEL: ret i32
52 declare i1 @llvm.type.test(i8*, metadata)
53 declare void @llvm.assume(i1)
54 declare i32 @_ZN1D1mEi(%struct.D* %this, i32 %a)
56 attributes #0 = { noinline optnone }
58 !3 = !{i64 16, !"_ZTS1D"}