93 lines · plain
1; REQUIRES: x86-registered-target2 3;; Check for successful devirtualization when vtable contains an alias,4;; and there is a single implementation.5 6;; Test pure ThinLTO7 8;; Generate unsplit module with summary for ThinLTO index-based WPD.9; RUN: opt -thinlto-bc -o %t1.o %s10 11;; Check that we have properly recorded the alias in the vtable summary.12; RUN: llvm-dis -o - %t1.o | FileCheck %s --check-prefix SUMMARY13; SUMMARY: gv: (name: "_ZTV1D", {{.*}} vTableFuncs: ((virtFunc: ^[[ALIAS:([0-9]+)]], offset: 16))14; SUMMARY: ^[[ALIAS]] = gv: (name: "_ZN1D1mEiAlias"15 16; RUN: llvm-lto2 run %t1.o -save-temps -pass-remarks=. \17; RUN: -whole-program-visibility \18; RUN: -wholeprogramdevirt-print-index-based \19; RUN: -o %t2 \20; RUN: -r=%t1.o,test,px \21; RUN: -r=%t1.o,_ZTV1D,px \22; RUN: -r=%t1.o,_ZN1D1mEi,px \23; RUN: -r=%t1.o,_ZN1D1mEiAlias,px \24; RUN: 2>&1 | FileCheck %s --check-prefix=REMARK --check-prefix=PRINT25; RUN: llvm-dis %t2.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR126 27; PRINT-DAG: Devirtualized call to {{.*}} (_ZN1D1mEiAlias)28; REMARK-DAG: single-impl: devirtualized a call to _ZN1D1mEiAlias29 30;; Test hybrid Thin/Regular LTO31 32;; Generate split module with summary for hybrid Thin/Regular LTO WPD.33; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t3.o %s34 35; RUN: llvm-lto2 run %t3.o -save-temps -pass-remarks=. \36; RUN: -whole-program-visibility \37; RUN: -o %t4 \38; RUN: -r=%t3.o,test,px \39; RUN: -r=%t3.o,_ZTV1D, \40; RUN: -r=%t3.o,_ZTV1D,px \41; RUN: -r=%t3.o,_ZN1D1mEi,px \42; RUN: -r=%t3.o,_ZN1D1mEiAlias,px \43; RUN: -r=%t3.o,_ZN1D1mEiAlias, \44; RUN: 2>&1 | FileCheck %s --check-prefix=REMARK45; RUN: llvm-dis %t4.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR146 47;; Test Regular LTO48; RUN: opt -o %t5.o %s49; RUN: llvm-lto2 run %t5.o -save-temps -pass-remarks=. \50; RUN: -whole-program-visibility \51; RUN: -o %t6 \52; RUN: -r=%t5.o,test,px \53; RUN: -r=%t5.o,_ZTV1D,px \54; RUN: -r=%t5.o,_ZN1D1mEi,px \55; RUN: -r=%t5.o,_ZN1D1mEiAlias,px \56; RUN: 2>&1 | FileCheck %s --check-prefix=REMARK57; RUN: llvm-dis %t6.0.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR158 59target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"60target triple = "x86_64-grtev4-linux-gnu"61 62%struct.D = type { ptr }63 64@_ZTV1D = constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr undef, ptr @_ZN1D1mEiAlias] }, !type !365 66define i32 @_ZN1D1mEi(ptr %this, i32 %a) {67 ret i32 0;68}69 70@_ZN1D1mEiAlias = unnamed_addr alias i32 (ptr, i32), ptr @_ZN1D1mEi71 72; CHECK-IR1-LABEL: define i32 @test73define i32 @test(ptr %obj2, i32 %a) {74entry:75 %vtable2 = load ptr, ptr %obj276 %p2 = call i1 @llvm.type.test(ptr %vtable2, metadata !"_ZTS1D")77 call void @llvm.assume(i1 %p2)78 79 %fptr33 = load ptr, ptr %vtable2, align 880 81 ;; Check that the call was devirtualized.82 ;; CHECK-IR1: %call4 = tail call i32 @_ZN1D1mEi83 %call4 = tail call i32 %fptr33(ptr nonnull %obj2, i32 %a)84 ret i32 %call485}86; CHECK-IR1-LABEL: ret i3287; CHECK-IR1-LABEL: }88 89declare i1 @llvm.type.test(ptr, metadata)90declare void @llvm.assume(i1)91 92!3 = !{i64 16, !"_ZTS1D"}93