xref: /llvm-project/llvm/test/Transforms/WholeProgramDevirt/devirt-single-impl2.ll (revision 200cc952a28a73687ba24d5334415df6332f2d5b)
1; Check that we can run WPD export using opt -passes=wholeprogramdevirt while
2; loading/saving index from/to bitcode
3; RUN: llvm-as %s -o %t.bc
4; RUN: llvm-as %p/Inputs/devirt-single-impl2-index.ll -o %t.index.bc
5; RUN: opt %s -S -passes=wholeprogramdevirt -whole-program-visibility -wholeprogramdevirt-read-summary=%t.index.bc \
6; RUN:     -wholeprogramdevirt-summary-action=export \
7; RUN:     -wholeprogramdevirt-write-summary=%t2.index.bc -o /dev/null
8; RUN: llvm-dis %t2.index.bc -o - | FileCheck %s
9
10; Check that opt fails to use summaries which don't contain regular LTO module
11; when performing export.
12; RUN: llvm-as %p/Inputs/devirt-bad-index.ll -o %t-bad.index.bc
13; RUN: not opt %s -S -passes=wholeprogramdevirt -whole-program-visibility -wholeprogramdevirt-read-summary=%t-bad.index.bc \
14; RUN:     -wholeprogramdevirt-summary-action=export -o /dev/null 2>&1 | FileCheck %s --check-prefix=MISSING-MODULE
15
16; Check single impl devirtulation in summary
17; CHECK: typeid: (name: "_ZTS1A", summary: (typeTestRes: (kind: unknown, sizeM1BitWidth: 0), wpdResolutions: ((offset: 0, wpdRes: (kind: singleImpl, singleImplName: "_ZNK1A1fEv"))))) ; guid
18
19; MISSING-MODULE: combined summary should contain Regular LTO module
20
21source_filename = "ld-temp.o"
22target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
23target triple = "x86_64-unknown-linux-gnu"
24
25%struct.A = type { ptr }
26
27$_ZTV1A = comdat any
28
29@_ZTV1A = weak_odr hidden unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI1A, ptr @_ZNK1A1fEv] }, comdat, align 8, !type !0, !type !1
30@_ZTI1A = external hidden constant { ptr, ptr }, align 8
31define available_externally hidden i32 @_ZNK1A1fEv(ptr %this) unnamed_addr align 2 {
32entry:
33  ret i32 3
34}
35
36!llvm.ident = !{!2}
37!llvm.module.flags = !{!3, !4, !5}
38
39!0 = !{i64 16, !"_ZTS1A"}
40!1 = !{i64 16, !"_ZTSM1AKFivE.virtual"}
41!2 = !{!"clang version 10.0.0 (trunk 373596)"}
42!3 = !{i32 1, !"wchar_size", i32 4}
43!4 = !{i32 1, !"EnableSplitLTOUnit", i32 1}
44!5 = !{i32 1, !"ThinLTO", i32 0}
45