1; REQUIRES: x86-registered-target 2 3; Test index-based devirtualization when one copy is an alias. 4 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 8 9; RUN: llvm-lto2 run %t3.o %t4.o -save-temps -pass-remarks=. \ 10; RUN: -whole-program-visibility \ 11; RUN: -wholeprogramdevirt-print-index-based \ 12; RUN: -o %t5 \ 13; RUN: -r=%t3.o,test,px \ 14; RUN: -r=%t3.o,_ZTV1D, \ 15; RUN: -r=%t3.o,_ZN1D1mEi, \ 16; RUN: -r=%t4.o,_ZN1D1mEi,p \ 17; RUN: -r=%t4.o,_ZTV1D,px \ 18; RUN: -r=%t4.o,some_name,px \ 19; RUN: 2>&1 | FileCheck %s --check-prefix=REMARK --check-prefix=PRINT 20; RUN: llvm-dis %t5.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR1 21 22; PRINT-DAG: Devirtualized call to {{.*}} (_ZN1D1mEi) 23 24; REMARK-DAG: single-impl: devirtualized a call to _ZN1D1mEi 25 26target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 27target triple = "x86_64-grtev4-linux-gnu" 28 29%struct.D = type { ptr } 30 31@_ZTV1D = linkonce_odr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr undef, ptr @_ZN1D1mEi] }, !type !3 32 33; CHECK-IR1-LABEL: define i32 @test 34define i32 @test(ptr %obj2, i32 %a) { 35entry: 36 %vtable2 = load ptr, ptr %obj2 37 %p2 = call i1 @llvm.type.test(ptr %vtable2, metadata !"_ZTS1D") 38 call void @llvm.assume(i1 %p2) 39 40 %fptr33 = load ptr, ptr %vtable2, align 8 41 42 ; Check that the call was devirtualized. 43 ; CHECK-IR1: %call4 = tail call i32 @_ZN1D1mEi 44 %call4 = tail call i32 %fptr33(ptr nonnull %obj2, i32 %a) 45 ret i32 %call4 46} 47; CHECK-IR1-LABEL: ret i32 48; CHECK-IR1-LABEL: } 49 50declare i1 @llvm.type.test(ptr, metadata) 51declare void @llvm.assume(i1) 52declare i32 @_ZN1D1mEi(ptr %this, i32 %a) 53 54attributes #0 = { noinline optnone } 55 56!3 = !{i64 16, !"_ZTS1D"} 57