1; Check that we import and inline virtual method with single implementation
2; when we're running hybrid LTO.
3;
4; RUN: opt -thinlto-bc -thinlto-split-lto-unit %s -o %t-main.bc
5; RUN: opt -thinlto-bc -thinlto-split-lto-unit %p/Inputs/devirt_single_hybrid_foo.ll -o %t-foo.bc
6; RUN: opt -thinlto-bc -thinlto-split-lto-unit %p/Inputs/devirt_single_hybrid_bar.ll -o %t-bar.bc
7; RUN: llvm-lto2 run -save-temps %t-main.bc %t-foo.bc %t-bar.bc -pass-remarks=. -o %t \
8; RUN:   -whole-program-visibility \
9; RUN:    -r=%t-foo.bc,_Z3fooP1A,pl \
10; RUN:    -r=%t-main.bc,main,plx \
11; RUN:    -r=%t-main.bc,_Z3barv,l \
12; RUN:    -r=%t-bar.bc,_Z3barv,pl \
13; RUN:    -r=%t-bar.bc,_Z3fooP1A, \
14; RUN:    -r=%t-bar.bc,_ZNK1A1fEv,pl \
15; RUN:    -r=%t-bar.bc,_ZTV1A,l \
16; RUN:    -r=%t-bar.bc,_ZTVN10__cxxabiv117__class_type_infoE, \
17; RUN:    -r=%t-bar.bc,_ZTS1A,pl \
18; RUN:    -r=%t-bar.bc,_ZTI1A,pl \
19; RUN:    -r=%t-bar.bc,_ZNK1A1fEv, \
20; RUN:    -r=%t-bar.bc,_ZTV1A,pl \
21; RUN:    -r=%t-bar.bc,_ZTI1A, 2>&1 | FileCheck %s --check-prefix=REMARK
22; RUN: llvm-dis %t.1.3.import.bc -o - | FileCheck %s --check-prefix=IMPORT
23; RUN: llvm-dis %t.1.5.precodegen.bc -o - | FileCheck %s --check-prefix=CODEGEN
24
25; REMARK-COUNT-3: single-impl: devirtualized a call to _ZNK1A1fEv
26
27; IMPORT:       define available_externally hidden i32 @_ZNK1A1fEv(%struct.A* %this)
28; IMPORT-NEXT:  entry:
29; IMPORT-NEXT:      ret i32 3
30
31; CODEGEN:        define hidden i32 @main()
32; CODEGEN-NEXT:   entry:
33; CODEGEN-NEXT:     ret i32 23
34
35; Virtual method should have been optimized out
36; CODEGEN-NOT: _ZNK1A1fEv
37
38; ModuleID = 'main.cpp'
39source_filename = "main.cpp"
40target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
41target triple = "x86_64-unknown-linux-gnu"
42
43; Function Attrs: norecurse uwtable
44define hidden i32 @main() local_unnamed_addr {
45entry:
46  %call = tail call i32 @_Z3barv()
47  ret i32 %call
48}
49
50declare dso_local i32 @_Z3barv() local_unnamed_addr
51
52!llvm.module.flags = !{!0}
53!llvm.ident = !{!1}
54
55!0 = !{i32 1, !"wchar_size", i32 4}
56!1 = !{!"clang version 10.0.0 (trunk 373596)"}
57