Skip to content

Commit a6fdde1

Browse files
committed
Reland #184065
1 parent ee890eb commit a6fdde1

125 files changed

Lines changed: 863 additions & 413 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,8 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
11161116
if (CodeGenOpts.FatLTO) {
11171117
MPM.addPass(PB.buildFatLTODefaultPipeline(
11181118
Level, PrepareForThinLTO,
1119-
PrepareForThinLTO || shouldEmitRegularLTOSummary()));
1119+
PrepareForThinLTO || shouldEmitRegularLTOSummary(),
1120+
CodeGenOpts.VerifyModule));
11201121
} else if (PrepareForThinLTO) {
11211122
MPM.addPass(PB.buildThinLTOPreLinkDefaultPipeline(Level));
11221123
} else if (PrepareForLTO) {

clang/lib/CodeGen/CGCUDANV.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "llvm/IR/BasicBlock.h"
2626
#include "llvm/IR/Constants.h"
2727
#include "llvm/IR/DerivedTypes.h"
28+
#include "llvm/IR/GlobalValue.h"
2829
#include "llvm/IR/ReplaceConstant.h"
2930
#include "llvm/ProfileData/InstrProf.h"
3031
#include "llvm/Support/Format.h"
@@ -1044,7 +1045,10 @@ llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() {
10441045
// Generate a unique module ID.
10451046
SmallString<64> ModuleID;
10461047
llvm::raw_svector_ostream OS(ModuleID);
1047-
OS << ModuleIDPrefix << llvm::format("%" PRIx64, FatbinWrapper->getGUID());
1048+
OS << ModuleIDPrefix
1049+
<< llvm::format("%" PRIx64,
1050+
llvm::GlobalValue::getGUIDAssumingExternalLinkage(
1051+
FatbinWrapper->getName()));
10481052
llvm::Constant *ModuleIDConstant = makeConstantArray(
10491053
std::string(ModuleID), "", ModuleIDSectionName, 32, /*AddNull=*/true);
10501054

clang/test/CodeGen/cfi-icall-trap-recover-runtime.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,32 @@
1515

1616

1717
// TRAP-LABEL: define hidden void @f(
18-
// TRAP-SAME: ) #[[ATTR0:[0-9]+]] !type [[META6:![0-9]+]] !type [[META7:![0-9]+]] {
18+
// TRAP-SAME: ) #[[ATTR0:[0-9]+]] !type [[META6:![0-9]+]] !type [[META7:![0-9]+]]
1919
// TRAP-NEXT: [[ENTRY:.*:]]
2020
// TRAP-NEXT: ret void
2121
//
2222
// ABORT-LABEL: define hidden void @f(
23-
// ABORT-SAME: ) #[[ATTR0:[0-9]+]] !type [[META6:![0-9]+]] !type [[META7:![0-9]+]] {
23+
// ABORT-SAME: ) #[[ATTR0:[0-9]+]] !type [[META6:![0-9]+]] !type [[META7:![0-9]+]]
2424
// ABORT-NEXT: [[ENTRY:.*:]]
2525
// ABORT-NEXT: ret void
2626
//
2727
// RECOVER-LABEL: define hidden void @f(
28-
// RECOVER-SAME: ) #[[ATTR0:[0-9]+]] !type [[META6:![0-9]+]] !type [[META7:![0-9]+]] {
28+
// RECOVER-SAME: ) #[[ATTR0:[0-9]+]] !type [[META6:![0-9]+]] !type [[META7:![0-9]+]]
2929
// RECOVER-NEXT: [[ENTRY:.*:]]
3030
// RECOVER-NEXT: ret void
3131
//
3232
// ABORT_MIN-LABEL: define hidden void @f(
33-
// ABORT_MIN-SAME: ) #[[ATTR0:[0-9]+]] !type [[META6:![0-9]+]] !type [[META7:![0-9]+]] {
33+
// ABORT_MIN-SAME: ) #[[ATTR0:[0-9]+]] !type [[META6:![0-9]+]] !type [[META7:![0-9]+]]
3434
// ABORT_MIN-NEXT: [[ENTRY:.*:]]
3535
// ABORT_MIN-NEXT: ret void
3636
//
3737
// RECOVER_MIN-LABEL: define hidden void @f(
38-
// RECOVER_MIN-SAME: ) #[[ATTR0:[0-9]+]] !type [[META6:![0-9]+]] !type [[META7:![0-9]+]] {
38+
// RECOVER_MIN-SAME: ) #[[ATTR0:[0-9]+]] !type [[META6:![0-9]+]] !type [[META7:![0-9]+]]
3939
// RECOVER_MIN-NEXT: [[ENTRY:.*:]]
4040
// RECOVER_MIN-NEXT: ret void
4141
//
4242
// PRESERVE_MIN-LABEL: define hidden void @f(
43-
// PRESERVE_MIN-SAME: ) #[[ATTR0:[0-9]+]] !type [[META6:![0-9]+]] !type [[META7:![0-9]+]] {
43+
// PRESERVE_MIN-SAME: ) #[[ATTR0:[0-9]+]] !type [[META6:![0-9]+]] !type [[META7:![0-9]+]]
4444
// PRESERVE_MIN-NEXT: [[ENTRY:.*:]]
4545
// PRESERVE_MIN-NEXT: ret void
4646
//
@@ -50,7 +50,7 @@ void f() {
5050
void xf();
5151

5252
// TRAP-LABEL: define hidden void @g(
53-
// TRAP-SAME: i32 noundef [[B:%.*]]) #[[ATTR0]] !type [[META8:![0-9]+]] !type [[META9:![0-9]+]] {
53+
// TRAP-SAME: i32 noundef [[B:%.*]]) #[[ATTR0]] !type [[META8:![0-9]+]] !type [[META9:![0-9]+]]
5454
// TRAP-NEXT: [[ENTRY:.*:]]
5555
// TRAP-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4
5656
// TRAP-NEXT: [[FP:%.*]] = alloca ptr, align 8
@@ -71,7 +71,7 @@ void xf();
7171
// TRAP-NEXT: ret void
7272
//
7373
// ABORT-LABEL: define hidden void @g(
74-
// ABORT-SAME: i32 noundef [[B:%.*]]) #[[ATTR0]] !type [[META8:![0-9]+]] !type [[META9:![0-9]+]] {
74+
// ABORT-SAME: i32 noundef [[B:%.*]]) #[[ATTR0]] !type [[META8:![0-9]+]] !type [[META9:![0-9]+]]
7575
// ABORT-NEXT: [[ENTRY:.*:]]
7676
// ABORT-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4
7777
// ABORT-NEXT: [[FP:%.*]] = alloca ptr, align 8
@@ -93,7 +93,7 @@ void xf();
9393
// ABORT-NEXT: ret void
9494
//
9595
// RECOVER-LABEL: define hidden void @g(
96-
// RECOVER-SAME: i32 noundef [[B:%.*]]) #[[ATTR0]] !type [[META8:![0-9]+]] !type [[META9:![0-9]+]] {
96+
// RECOVER-SAME: i32 noundef [[B:%.*]]) #[[ATTR0]] !type [[META8:![0-9]+]] !type [[META9:![0-9]+]]
9797
// RECOVER-NEXT: [[ENTRY:.*:]]
9898
// RECOVER-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4
9999
// RECOVER-NEXT: [[FP:%.*]] = alloca ptr, align 8
@@ -115,7 +115,7 @@ void xf();
115115
// RECOVER-NEXT: ret void
116116
//
117117
// ABORT_MIN-LABEL: define hidden void @g(
118-
// ABORT_MIN-SAME: i32 noundef [[B:%.*]]) #[[ATTR0]] !type [[META8:![0-9]+]] !type [[META9:![0-9]+]] {
118+
// ABORT_MIN-SAME: i32 noundef [[B:%.*]]) #[[ATTR0]] !type [[META8:![0-9]+]] !type [[META9:![0-9]+]]
119119
// ABORT_MIN-NEXT: [[ENTRY:.*:]]
120120
// ABORT_MIN-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4
121121
// ABORT_MIN-NEXT: [[FP:%.*]] = alloca ptr, align 8
@@ -136,7 +136,7 @@ void xf();
136136
// ABORT_MIN-NEXT: ret void
137137
//
138138
// RECOVER_MIN-LABEL: define hidden void @g(
139-
// RECOVER_MIN-SAME: i32 noundef [[B:%.*]]) #[[ATTR0]] !type [[META8:![0-9]+]] !type [[META9:![0-9]+]] {
139+
// RECOVER_MIN-SAME: i32 noundef [[B:%.*]]) #[[ATTR0]] !type [[META8:![0-9]+]] !type [[META9:![0-9]+]]
140140
// RECOVER_MIN-NEXT: [[ENTRY:.*:]]
141141
// RECOVER_MIN-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4
142142
// RECOVER_MIN-NEXT: [[FP:%.*]] = alloca ptr, align 8
@@ -157,7 +157,7 @@ void xf();
157157
// RECOVER_MIN-NEXT: ret void
158158
//
159159
// PRESERVE_MIN-LABEL: define hidden void @g(
160-
// PRESERVE_MIN-SAME: i32 noundef [[B:%.*]]) #[[ATTR0]] !type [[META8:![0-9]+]] !type [[META9:![0-9]+]] {
160+
// PRESERVE_MIN-SAME: i32 noundef [[B:%.*]]) #[[ATTR0]] !type [[META8:![0-9]+]] !type [[META9:![0-9]+]]
161161
// PRESERVE_MIN-NEXT: [[ENTRY:.*:]]
162162
// PRESERVE_MIN-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4
163163
// PRESERVE_MIN-NEXT: [[FP:%.*]] = alloca ptr, align 8

clang/test/CodeGen/lto-newpm-pipeline.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
// CHECK-FULL-O0-NEXT: Running pass: CoroConditionalWrapper
3535
// CHECK-FULL-O0-NEXT: Running pass: CanonicalizeAliasesPass
3636
// CHECK-FULL-O0-NEXT: Running pass: NameAnonGlobalPass
37+
// CHECK-FULL-O0-NEXT: Running pass: AssignGUIDPass
3738
// CHECK-FULL-O0-NEXT: Running pass: AnnotationRemarksPass
3839
// CHECK-FULL-O0-NEXT: Running analysis: TargetLibraryAnalysis
3940
// CHECK-FULL-O0-NEXT: Running pass: VerifierPass
@@ -48,6 +49,7 @@
4849
// CHECK-THIN-O0-NEXT: Running pass: CoroConditionalWrapper
4950
// CHECK-THIN-O0-NEXT: Running pass: CanonicalizeAliasesPass
5051
// CHECK-THIN-O0-NEXT: Running pass: NameAnonGlobalPass
52+
// CHECK-THIN-O0-NEXT: Running pass: AssignGUIDPass
5153
// CHECK-THIN-O0-NEXT: Running pass: AnnotationRemarksPass
5254
// CHECK-THIN-O0-NEXT: Running analysis: TargetLibraryAnalysis
5355
// CHECK-THIN-O0-NEXT: Running pass: VerifierPass
@@ -64,6 +66,7 @@
6466
// CHECK-THIN-OPTIMIZED-NOT: Running pass: LoopVectorizePass
6567
// CHECK-THIN-OPTIMIZED: Running pass: CanonicalizeAliasesPass
6668
// CHECK-THIN-OPTIMIZED: Running pass: NameAnonGlobalPass
69+
// CHECK-THIN-OPTIMIZED: Running pass: AssignGUIDPass
6770
// CHECK-THIN-OPTIMIZED: Running pass: ThinLTOBitcodeWriterPass
6871

6972
void Foo(void) {}

clang/test/CodeGenCXX/cfi-vcall-trap-recover-runtime.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct S1 {
1919
};
2020

2121
// TRAP-LABEL: define hidden void @_Z3s1fP2S1(
22-
// TRAP-SAME: ptr noundef [[S1:%.*]]) #[[ATTR0:[0-9]+]] {
22+
// TRAP-SAME: ptr noundef [[S1:%.*]]) #[[ATTR0:[0-9]+]]
2323
// TRAP-NEXT: [[ENTRY:.*:]]
2424
// TRAP-NEXT: [[S1_ADDR:%.*]] = alloca ptr, align 8
2525
// TRAP-NEXT: store ptr [[S1]], ptr [[S1_ADDR]], align 8
@@ -37,7 +37,7 @@ struct S1 {
3737
// TRAP-NEXT: ret void
3838
//
3939
// ABORT-LABEL: define hidden void @_Z3s1fP2S1(
40-
// ABORT-SAME: ptr noundef [[S1:%.*]]) #[[ATTR0:[0-9]+]] {
40+
// ABORT-SAME: ptr noundef [[S1:%.*]]) #[[ATTR0:[0-9]+]]
4141
// ABORT-NEXT: [[ENTRY:.*:]]
4242
// ABORT-NEXT: [[S1_ADDR:%.*]] = alloca ptr, align 8
4343
// ABORT-NEXT: store ptr [[S1]], ptr [[S1_ADDR]], align 8
@@ -58,7 +58,7 @@ struct S1 {
5858
// ABORT-NEXT: ret void
5959
//
6060
// RECOVER-LABEL: define hidden void @_Z3s1fP2S1(
61-
// RECOVER-SAME: ptr noundef [[S1:%.*]]) #[[ATTR0:[0-9]+]] {
61+
// RECOVER-SAME: ptr noundef [[S1:%.*]]) #[[ATTR0:[0-9]+]]
6262
// RECOVER-NEXT: [[ENTRY:.*:]]
6363
// RECOVER-NEXT: [[S1_ADDR:%.*]] = alloca ptr, align 8
6464
// RECOVER-NEXT: store ptr [[S1]], ptr [[S1_ADDR]], align 8
@@ -79,7 +79,7 @@ struct S1 {
7979
// RECOVER-NEXT: ret void
8080
//
8181
// ABORT_MIN-LABEL: define hidden void @_Z3s1fP2S1(
82-
// ABORT_MIN-SAME: ptr noundef [[S1:%.*]]) #[[ATTR0:[0-9]+]] {
82+
// ABORT_MIN-SAME: ptr noundef [[S1:%.*]]) #[[ATTR0:[0-9]+]]
8383
// ABORT_MIN-NEXT: [[ENTRY:.*:]]
8484
// ABORT_MIN-NEXT: [[S1_ADDR:%.*]] = alloca ptr, align 8
8585
// ABORT_MIN-NEXT: store ptr [[S1]], ptr [[S1_ADDR]], align 8
@@ -98,7 +98,7 @@ struct S1 {
9898
// ABORT_MIN-NEXT: ret void
9999
//
100100
// RECOVER_MIN-LABEL: define hidden void @_Z3s1fP2S1(
101-
// RECOVER_MIN-SAME: ptr noundef [[S1:%.*]]) #[[ATTR0:[0-9]+]] {
101+
// RECOVER_MIN-SAME: ptr noundef [[S1:%.*]]) #[[ATTR0:[0-9]+]]
102102
// RECOVER_MIN-NEXT: [[ENTRY:.*:]]
103103
// RECOVER_MIN-NEXT: [[S1_ADDR:%.*]] = alloca ptr, align 8
104104
// RECOVER_MIN-NEXT: store ptr [[S1]], ptr [[S1_ADDR]], align 8
@@ -117,7 +117,7 @@ struct S1 {
117117
// RECOVER_MIN-NEXT: ret void
118118
//
119119
// PRESERVE_MIN-LABEL: define hidden void @_Z3s1fP2S1(
120-
// PRESERVE_MIN-SAME: ptr noundef [[S1:%.*]]) #[[ATTR0:[0-9]+]] {
120+
// PRESERVE_MIN-SAME: ptr noundef [[S1:%.*]]) #[[ATTR0:[0-9]+]]
121121
// PRESERVE_MIN-NEXT: [[ENTRY:.*:]]
122122
// PRESERVE_MIN-NEXT: [[S1_ADDR:%.*]] = alloca ptr, align 8
123123
// PRESERVE_MIN-NEXT: store ptr [[S1]], ptr [[S1_ADDR]], align 8

lld/test/ELF/lto/devirt_vcall_vis_export_dynamic.ll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
;; Index based WPD
77
;; Generate unsplit module with summary for ThinLTO index-based WPD.
8-
; RUN: opt --thinlto-bc -o %t2.o %s
8+
; RUN: opt --passes=assign-guid --thinlto-bc -o %t2.o %s
99
; RUN: ld.lld %t2.o -o %t3 -save-temps --lto-whole-program-visibility \
1010
; RUN: -mllvm -pass-remarks=. 2>&1 | FileCheck %s --check-prefix=REMARK
1111
; RUN: llvm-dis %t2.o.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
@@ -16,13 +16,13 @@
1616

1717
;; Hybrid WPD
1818
;; Generate split module with summary for hybrid Thin/Regular LTO WPD.
19-
; RUN: opt --thinlto-bc --thinlto-split-lto-unit -o %t.o %s
19+
; RUN: opt --passes=assign-guid --thinlto-bc --thinlto-split-lto-unit -o %t.o %s
2020
; RUN: ld.lld %t.o -o %t3 -save-temps --lto-whole-program-visibility \
2121
; RUN: -mllvm -pass-remarks=. 2>&1 | FileCheck %s --check-prefix=REMARK
2222
; RUN: llvm-dis %t.o.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
2323

2424
;; Regular LTO WPD
25-
; RUN: opt -o %t4.o %s
25+
; RUN: opt --passes=assign-guid -o %t4.o %s
2626
; RUN: ld.lld %t4.o -o %t3 -save-temps --lto-whole-program-visibility \
2727
; RUN: -mllvm -pass-remarks=. 2>&1 | FileCheck %s --check-prefix=REMARK
2828
; RUN: llvm-dis %t3.0.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
@@ -107,19 +107,19 @@
107107
;; preemption, even without any options.
108108

109109
;; Index based WPD
110-
; RUN: opt -relocation-model=pic --thinlto-bc -o %t5.o %s
110+
; RUN: opt --passes=assign-guid -relocation-model=pic --thinlto-bc -o %t5.o %s
111111
; RUN: ld.lld %t5.o -o %t5.so -shared
112112
; RUN: ld.lld %t5.o %t5.so -o %t5 -save-temps --lto-whole-program-visibility \
113113
; RUN: -mllvm -pass-remarks=. 2>&1 | FileCheck /dev/null --implicit-check-not single-impl --allow-empty
114114

115115
;; Hybrid WPD
116-
; RUN: opt -relocation-model=pic --thinlto-bc --thinlto-split-lto-unit -o %t5.o %s
116+
; RUN: opt --passes=assign-guid -relocation-model=pic --thinlto-bc --thinlto-split-lto-unit -o %t5.o %s
117117
; RUN: ld.lld %t5.o -o %t5.so -shared
118118
; RUN: ld.lld %t5.o %t5.so -o %t5 -save-temps --lto-whole-program-visibility \
119119
; RUN: -mllvm -pass-remarks=. 2>&1 | FileCheck /dev/null --implicit-check-not single-impl --allow-empty
120120

121121
;; Regular LTO WPD
122-
; RUN: opt -relocation-model=pic -o %t5.o %s
122+
; RUN: opt --passes=assign-guid -relocation-model=pic -o %t5.o %s
123123
; RUN: ld.lld %t5.o -o %t5.so -shared
124124
; RUN: ld.lld %t5.o %t5.so -o %t5 -save-temps --lto-whole-program-visibility \
125125
; RUN: -mllvm -pass-remarks=. 2>&1 | FileCheck /dev/null --implicit-check-not single-impl --allow-empty

lld/test/ELF/lto/devirt_vcall_vis_public.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33

44
;; Index based WPD
55
;; Generate unsplit module with summary for ThinLTO index-based WPD.
6-
; RUN: opt --thinlto-bc -o %t2.o %s
6+
; RUN: opt --passes=assign-guid --thinlto-bc -o %t2.o %s
77
; RUN: ld.lld %t2.o -o %t3 -save-temps --lto-whole-program-visibility \
88
; RUN: -mllvm -pass-remarks=. 2>&1 | FileCheck %s --check-prefix=REMARK
99
; RUN: llvm-dis %t2.o.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
1010

1111
;; Hybrid WPD
1212
;; Generate split module with summary for hybrid Thin/Regular LTO WPD.
13-
; RUN: opt --thinlto-bc --thinlto-split-lto-unit -o %t.o %s
13+
; RUN: opt --passes=assign-guid --thinlto-bc --thinlto-split-lto-unit -o %t.o %s
1414
; RUN: ld.lld %t.o -o %t3 -save-temps --lto-whole-program-visibility \
1515
; RUN: -mllvm -pass-remarks=. 2>&1 | FileCheck %s --check-prefix=REMARK
1616
; RUN: llvm-dis %t.o.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
1717

1818
;; Regular LTO WPD
19-
; RUN: opt -o %t4.o %s
19+
; RUN: opt --passes=assign-guid -o %t4.o %s
2020
; RUN: ld.lld %t4.o -o %t3 -save-temps --lto-whole-program-visibility \
2121
; RUN: -mllvm -pass-remarks=. 2>&1 | FileCheck %s --check-prefix=REMARK
2222
; RUN: llvm-dis %t3.0.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR

lld/test/ELF/lto/devirt_vcall_vis_shared_def.ll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@
66

77
;; Index based WPD
88
;; Generate unsplit module with summary for ThinLTO index-based WPD.
9-
; RUN: opt --thinlto-bc -o %t1a.o %s
10-
; RUN: opt --thinlto-bc -o %t2a.o %S/Inputs/devirt_vcall_vis_shared_def.ll
9+
; RUN: opt --passes=assign-guid --thinlto-bc -o %t1a.o %s
10+
; RUN: opt --passes=assign-guid --thinlto-bc -o %t2a.o %S/Inputs/devirt_vcall_vis_shared_def.ll
1111
; RUN: ld.lld %t1a.o %t2a.o -o %t3a -save-temps --lto-whole-program-visibility \
1212
; RUN: -mllvm -pass-remarks=. 2>&1 | FileCheck %s --check-prefix=REMARK
1313
; RUN: llvm-dis %t1a.o.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
1414

1515
;; Hybrid WPD
1616
;; Generate split module with summary for hybrid Thin/Regular LTO WPD.
17-
; RUN: opt --thinlto-bc --thinlto-split-lto-unit -o %t1b.o %s
18-
; RUN: opt --thinlto-bc --thinlto-split-lto-unit -o %t2b.o %S/Inputs/devirt_vcall_vis_shared_def.ll
17+
; RUN: opt --passes=assign-guid --thinlto-bc --thinlto-split-lto-unit -o %t1b.o %s
18+
; RUN: opt --passes=assign-guid --thinlto-bc --thinlto-split-lto-unit -o %t2b.o %S/Inputs/devirt_vcall_vis_shared_def.ll
1919
; RUN: ld.lld %t1b.o %t2b.o -o %t3b -save-temps --lto-whole-program-visibility \
2020
; RUN: -mllvm -pass-remarks=. 2>&1 | FileCheck %s --check-prefix=REMARK
2121
; RUN: llvm-dis %t1b.o.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
2222

2323
;; Regular LTO WPD
24-
; RUN: opt -o %t1c.o %s
25-
; RUN: opt -o %t2c.o %S/Inputs/devirt_vcall_vis_shared_def.ll
24+
; RUN: opt --passes=assign-guid -o %t1c.o %s
25+
; RUN: opt --passes=assign-guid -o %t2c.o %S/Inputs/devirt_vcall_vis_shared_def.ll
2626
; RUN: ld.lld %t1c.o %t2c.o -o %t3c -save-temps --lto-whole-program-visibility \
2727
; RUN: -mllvm -pass-remarks=. 2>&1 | FileCheck %s --check-prefix=REMARK
2828
; RUN: llvm-dis %t3c.0.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR

llvm/include/llvm/Analysis/CtxProfAnalysis.h

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ class PGOContextualProfile {
4747
// we'll need when we maintain the profiles during IPO transformations.
4848
std::map<GlobalValue::GUID, FunctionInfo> FuncInfo;
4949

50-
/// Get the GUID of this Function if it's defined in this module.
51-
LLVM_ABI GlobalValue::GUID getDefinedFunctionGUID(const Function &F) const;
52-
5350
// This is meant to be constructed from CtxProfAnalysis, which will also set
5451
// its state piecemeal.
5552
PGOContextualProfile() = default;
@@ -68,9 +65,7 @@ class PGOContextualProfile {
6865

6966
LLVM_ABI bool isInSpecializedModule() const;
7067

71-
bool isFunctionKnown(const Function &F) const {
72-
return getDefinedFunctionGUID(F) != 0;
73-
}
68+
bool isFunctionKnown(const Function &F) const { return !F.isDeclaration(); }
7469

7570
StringRef getFunctionName(GlobalValue::GUID GUID) const {
7671
auto It = FuncInfo.find(GUID);
@@ -81,22 +76,22 @@ class PGOContextualProfile {
8176

8277
uint32_t getNumCounters(const Function &F) const {
8378
assert(isFunctionKnown(F));
84-
return FuncInfo.find(getDefinedFunctionGUID(F))->second.NextCounterIndex;
79+
return FuncInfo.find(F.getGUID())->second.NextCounterIndex;
8580
}
8681

8782
uint32_t getNumCallsites(const Function &F) const {
8883
assert(isFunctionKnown(F));
89-
return FuncInfo.find(getDefinedFunctionGUID(F))->second.NextCallsiteIndex;
84+
return FuncInfo.find(F.getGUID())->second.NextCallsiteIndex;
9085
}
9186

9287
uint32_t allocateNextCounterIndex(const Function &F) {
9388
assert(isFunctionKnown(F));
94-
return FuncInfo.find(getDefinedFunctionGUID(F))->second.NextCounterIndex++;
89+
return FuncInfo.find(F.getGUID())->second.NextCounterIndex++;
9590
}
9691

9792
uint32_t allocateNextCallsiteIndex(const Function &F) {
9893
assert(isFunctionKnown(F));
99-
return FuncInfo.find(getDefinedFunctionGUID(F))->second.NextCallsiteIndex++;
94+
return FuncInfo.find(F.getGUID())->second.NextCallsiteIndex++;
10095
}
10196

10297
using ConstVisitor = function_ref<void(const PGOCtxProfContext &)>;
@@ -187,26 +182,5 @@ class ProfileAnnotator {
187182
LLVM_ABI ~ProfileAnnotator();
188183
};
189184

190-
/// Assign a GUID to functions as metadata. GUID calculation takes linkage into
191-
/// account, which may change especially through and after thinlto. By
192-
/// pre-computing and assigning as metadata, this mechanism is resilient to such
193-
/// changes (as well as name changes e.g. suffix ".llvm." additions).
194-
195-
// FIXME(mtrofin): we can generalize this mechanism to calculate a GUID early in
196-
// the pass pipeline, associate it with any Global Value, and then use it for
197-
// PGO and ThinLTO.
198-
// At that point, this should be moved elsewhere.
199-
class AssignGUIDPass : public OptionalPassInfoMixin<AssignGUIDPass> {
200-
public:
201-
explicit AssignGUIDPass() = default;
202-
203-
/// Assign a GUID *if* one is not already assign, as a function metadata named
204-
/// `GUIDMetadataName`.
205-
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
206-
LLVM_ABI static const char *GUIDMetadataName;
207-
// This should become GlobalValue::getGUID
208-
LLVM_ABI static uint64_t getGUID(const Function &F);
209-
};
210-
211185
} // namespace llvm
212186
#endif // LLVM_ANALYSIS_CTXPROFANALYSIS_H

llvm/include/llvm/Bitcode/BitcodeReader.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "llvm/ADT/StringRef.h"
1818
#include "llvm/Bitstream/BitCodeEnums.h"
1919
#include "llvm/IR/GlobalValue.h"
20+
#include "llvm/IR/ModuleSummaryIndex.h"
2021
#include "llvm/Support/Compiler.h"
2122
#include "llvm/Support/Endian.h"
2223
#include "llvm/Support/Error.h"
@@ -165,7 +166,8 @@ struct ParserCallbacks {
165166
/// into CombinedIndex.
166167
LLVM_ABI Error
167168
readSummary(ModuleSummaryIndex &CombinedIndex, StringRef ModulePath,
168-
std::function<bool(GlobalValue::GUID)> IsPrevailing = nullptr);
169+
std::function<bool(StringRef)> IsPrevailing = nullptr,
170+
std::function<void(ValueInfo)> OnValueInfo = nullptr);
169171
};
170172

171173
struct BitcodeFileContents {

0 commit comments

Comments
 (0)