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: --pass-remarks=. \
14 ; RUN: --exported-symbol=test \
15 ; RUN: --exported-symbol=test2 \
16 ; RUN: --exported-symbol=_ZTV1B 2>&1 | FileCheck %s --check-prefix=REMARK
17 ; RUN: llvm-dis %t5.0.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR1
18 ; RUN: llvm-dis %t5.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR2
20 ; We should devirt call to _ZN1A1nEi once in importing module and once
21 ; in original (exporting) module.
22 ; REMARK-COUNT-2: single-impl: devirtualized a call to _ZN1A1nEi.llvm.
24 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
25 target triple = "x86_64-grtev4-linux-gnu"
27 %struct.A = type { i32 (...)** }
29 ; CHECK-IR1-LABEL: define i32 @test
30 define i32 @test(%struct.A* %obj, i32 %a) {
32 %0 = bitcast %struct.A* %obj to i8***
33 %vtable = load i8**, i8*** %0
34 %1 = bitcast i8** %vtable to i8*
35 %p = call i1 @llvm.type.test(i8* %1, metadata !"_ZTS1A")
36 call void @llvm.assume(i1 %p)
37 %fptrptr = getelementptr i8*, i8** %vtable, i32 1
38 %2 = bitcast i8** %fptrptr to i32 (%struct.A*, i32)**
39 %fptr1 = load i32 (%struct.A*, i32)*, i32 (%struct.A*, i32)** %2, align 8
41 ; Check that the call was devirtualized.
42 ; CHECK-IR1: = tail call i32 bitcast (void ()* @_ZN1A1nEi
43 %call = tail call i32 %fptr1(%struct.A* nonnull %obj, i32 %a)
47 ; CHECK-IR1-LABEL: ret i32
50 ; CHECK-IR2: define i32 @test2
51 ; Check that the call was devirtualized.
52 ; CHECK-IR2: = tail call i32 @_ZN1A1nEi
54 declare i1 @llvm.type.test(i8*, metadata)
55 declare void @llvm.assume(i1)
57 attributes #0 = { noinline optnone }