1 ; REQUIRES: x86-registered-target
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
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
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
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.
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.A = type { ptr }
30 ; CHECK-IR1-LABEL: define i32 @test
31 define i32 @test(ptr %obj, i32 %a) {
33 %vtable = load ptr, ptr %obj
34 %p = call i1 @llvm.type.test(ptr %vtable, metadata !"_ZTS1A")
35 call void @llvm.assume(i1 %p)
36 %fptrptr = getelementptr ptr, ptr %vtable, i32 1
37 %fptr1 = load ptr, ptr %fptrptr, align 8
39 ; Check that the call was devirtualized.
40 ; CHECK-IR1: = tail call i32 @_ZN1A1nEi
41 %call = tail call i32 %fptr1(ptr nonnull %obj, i32 %a)
45 ; CHECK-IR1-LABEL: ret i32
48 ; CHECK-IR2: define noundef i32 @test2
49 ; Check that the call was devirtualized.
50 ; CHECK-IR2: = tail call i32 @_ZN1A1nEi
52 declare i1 @llvm.type.test(ptr, metadata)
53 declare void @llvm.assume(i1)
55 attributes #0 = { noinline optnone }