1 ; REQUIRES: x86-registered-target
3 ; Test that index-based devirtualization in the presence of same-named
4 ; local vtables in same named source files fails.
6 ; Generate unsplit module with summary for ThinLTO index-based WPD.
7 ; RUN: opt -thinlto-bc -o %t3.o %s
8 ; RUN: opt -thinlto-bc -o %t4.o %p/Inputs/devirt_local_same_guid.ll
10 ; RUN: llvm-lto2 run %t3.o %t4.o -save-temps -pass-remarks=. \
11 ; RUN: -wholeprogramdevirt-print-index-based \
13 ; RUN: -r=%t3.o,use_B,px \
14 ; RUN: -r=%t3.o,test,px \
15 ; RUN: -r=%t4.o,test2,px
16 ; RUN: llvm-dis %t5.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR1
17 ; RUN: llvm-dis %t5.2.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR2
19 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
20 target triple = "x86_64-grtev4-linux-gnu"
24 %struct.A = type { ptr }
25 %struct.B = type { %struct.A }
27 @_ZTV1B = internal constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr undef, ptr @_ZN1B1fEi, ptr @_ZN1B1nEi] }, !type !0, !type !1
29 define internal i32 @_ZN1B1fEi(ptr %this, i32 %a) #0 {
33 define internal i32 @_ZN1B1nEi(ptr %this, i32 %a) #0 {
37 ; Ensures that vtable of B is live so that we will attempt devirt.
38 define dso_local i32 @use_B(ptr %a) {
40 store ptr getelementptr inbounds ({ [4 x ptr] }, ptr @_ZTV1B, i64 0, i32 0, i64 2), ptr %a, align 8
44 ; CHECK-IR1: define i32 @test(
45 define i32 @test(ptr %obj, i32 %a) {
47 %vtable = load ptr, ptr %obj
48 %p = call i1 @llvm.type.test(ptr %vtable, metadata !"_ZTS1A")
49 call void @llvm.assume(i1 %p)
50 %fptrptr = getelementptr ptr, ptr %vtable, i32 1
51 %fptr1 = load ptr, ptr %fptrptr, align 8
53 ; Check that the call was not devirtualized.
54 ; CHECK-IR1: %call = tail call i32 %fptr1
55 %call = tail call i32 %fptr1(ptr nonnull %obj, i32 %a)
60 ; CHECK-IR2: define i32 @test2
61 ; Check that the call was not devirtualized.
62 ; CHECK-IR2: %call4 = tail call i32 %fptr
64 declare i1 @llvm.type.test(ptr, metadata)
65 declare void @llvm.assume(i1)
67 attributes #0 = { noinline optnone }
69 !0 = !{i64 16, !"_ZTS1A"}
70 !1 = !{i64 16, !"_ZTS1B"}