71 lines · plain
1; REQUIRES: x86-registered-target2 3; Test index-based devirtualization when first copy is available_externally,4; which doesn't have type metadata. We should use the strong external5; def in the other module to devirtualize.6 7; Generate unsplit module with summary for ThinLTO index-based WPD.8; RUN: opt -thinlto-bc -o %t3.o %s9; RUN: opt -thinlto-bc -o %t4.o %p/Inputs/devirt_available_externally.ll10 11; The available_externally copy should not get vTableFuncs information in its12; summary entry, but the external def should.13; RUN: llvm-dis -o - %t3.o | FileCheck %s --check-prefix=AVAILEXTERNAL14; AVAILEXTERNAL: gv: (name: "_ZTV1D"15; AVAILEXTERNAL-NOT: vTableFuncs16; AVAILEXTERNAL-SAME: ; guid =17; RUN: llvm-dis -o - %t4.o | FileCheck %s --check-prefix=EXTERNAL18; EXTERNAL: gv: (name: "_ZTV1D", {{.*}} vTableFuncs: ((virtFunc:19 20; RUN: llvm-lto2 run %t3.o %t4.o -save-temps -pass-remarks=. \21; RUN: -whole-program-visibility \22; RUN: -wholeprogramdevirt-print-index-based \23; RUN: -o %t5 \24; RUN: -r=%t3.o,test,px \25; RUN: -r=%t3.o,_ZTV1D, \26; RUN: -r=%t3.o,_ZN1D1mEi, \27; RUN: -r=%t4.o,_ZN1D1mEi,p \28; RUN: -r=%t4.o,_ZTV1D,px \29; RUN: 2>&1 | FileCheck %s --check-prefix=REMARK --check-prefix=PRINT30; RUN: llvm-dis %t5.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR131; RUN: llvm-nm %t5.1 | FileCheck %s --check-prefix=NM-INDEX132; RUN: llvm-nm %t5.2 | FileCheck %s --check-prefix=NM-INDEX233 34; NM-INDEX1-DAG: U _ZN1D1mEi35 36; NM-INDEX2-DAG: T _ZN1D1mEi37 38; PRINT-DAG: Devirtualized call to {{.*}} (_ZN1D1mEi)39 40; REMARK-DAG: single-impl: devirtualized a call to _ZN1D1mEi41 42target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"43target triple = "x86_64-grtev4-linux-gnu"44 45%struct.D = type { ptr }46 47@_ZTV1D = available_externally constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr undef, ptr @_ZN1D1mEi] }48 49; CHECK-IR1-LABEL: define i32 @test50define i32 @test(ptr %obj2, i32 %a) {51entry:52 %vtable2 = load ptr, ptr %obj253 %p2 = call i1 @llvm.type.test(ptr %vtable2, metadata !"_ZTS1D")54 call void @llvm.assume(i1 %p2)55 56 %fptr33 = load ptr, ptr %vtable2, align 857 58 ; Check that the call was devirtualized.59 ; CHECK-IR1: %call4 = tail call i32 @_ZN1D1mEi60 %call4 = tail call i32 %fptr33(ptr nonnull %obj2, i32 %a)61 ret i32 %call462}63; CHECK-IR1-LABEL: ret i3264; CHECK-IR1-LABEL: }65 66declare i1 @llvm.type.test(ptr, metadata)67declare void @llvm.assume(i1)68declare i32 @_ZN1D1mEi(ptr %this, i32 %a)69 70attributes #0 = { noinline optnone }71