1; REQUIRES: x86-registered-target 2 3; Test devirtualization requiring promotion of local targets, where the 4; promotion is required by one devirtualization and needs to be updated 5; for a second devirtualization in the defining module as a post-pass 6; update. 7 8; Generate unsplit module with summary for ThinLTO index-based WPD. 9; RUN: opt -thinlto-bc -o %t3.o %s 10; RUN: opt -thinlto-bc -o %t4.o %p/Inputs/devirt_promote.ll 11 12; RUN: llvm-lto -thinlto-action=run %t3.o %t4.o --thinlto-save-temps=%t5. \ 13; RUN: -whole-program-visibility \ 14; RUN: --pass-remarks=. \ 15; RUN: --exported-symbol=test \ 16; RUN: --exported-symbol=test2 \ 17; RUN: --exported-symbol=_ZTV1B 2>&1 | FileCheck %s --check-prefix=REMARK 18; RUN: llvm-dis %t5.0.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR1 19; RUN: llvm-dis %t5.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR2 20 21; We should devirt call to _ZN1A1nEi once in importing module and once 22; in original (exporting) module. 23; REMARK-COUNT-2: single-impl: devirtualized a call to _ZN1A1nEi.llvm. 24 25target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 26target triple = "x86_64-grtev4-linux-gnu" 27 28%struct.A = type { i32 (...)** } 29 30; CHECK-IR1-LABEL: define i32 @test 31define i32 @test(%struct.A* %obj, i32 %a) { 32entry: 33 %0 = bitcast %struct.A* %obj to i8*** 34 %vtable = load i8**, i8*** %0 35 %1 = bitcast i8** %vtable to i8* 36 %p = call i1 @llvm.type.test(i8* %1, metadata !"_ZTS1A") 37 call void @llvm.assume(i1 %p) 38 %fptrptr = getelementptr i8*, i8** %vtable, i32 1 39 %2 = bitcast i8** %fptrptr to i32 (%struct.A*, i32)** 40 %fptr1 = load i32 (%struct.A*, i32)*, i32 (%struct.A*, i32)** %2, align 8 41 42 ; Check that the call was devirtualized. 43 ; CHECK-IR1: = tail call i32 bitcast (void ()* @_ZN1A1nEi 44 %call = tail call i32 %fptr1(%struct.A* nonnull %obj, i32 %a) 45 46 ret i32 %call 47} 48; CHECK-IR1-LABEL: ret i32 49; CHECK-IR1-LABEL: } 50 51; CHECK-IR2: define i32 @test2 52; Check that the call was devirtualized. 53; CHECK-IR2: = tail call i32 @_ZN1A1nEi 54 55declare i1 @llvm.type.test(i8*, metadata) 56declare void @llvm.assume(i1) 57 58attributes #0 = { noinline optnone } 59