Skip to content

Commit 3489b48

Browse files
committed
[ctxprof] Use isInSpecializedModule as criteria for using contextual profile
1 parent 00357fe commit 3489b48

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

llvm/lib/Transforms/IPO/ModuleInliner.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ PreservedAnalyses ModuleInlinerPass::run(Module &M,
171171
<< setIsVerbose();
172172
});
173173
}
174-
} else if (CtxProfPromoteAlwaysInline && !CtxProf.contexts().empty() &&
175-
CB->isIndirectCall()) {
174+
} else if (CtxProfPromoteAlwaysInline &&
175+
CtxProf.isInSpecializedModule() && CB->isIndirectCall()) {
176176
CtxProfAnalysis::collectIndirectCallPromotionList(*CB, CtxProf,
177177
ICPCandidates);
178178
}
@@ -260,7 +260,7 @@ PreservedAnalyses ModuleInlinerPass::run(Module &M,
260260
// iteration because the next iteration may not happen and we may
261261
// miss inlining it.
262262
// FIXME: enable for ctxprof.
263-
if (CtxProf.contexts().empty())
263+
if (CtxProf.isInSpecializedModule())
264264
if (tryPromoteCall(*ICB))
265265
NewCallee = ICB->getCalledFunction();
266266
}

llvm/lib/Transforms/Utils/InlineFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2356,7 +2356,7 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
23562356
AAResults *CalleeAAR,
23572357
bool InsertLifetime,
23582358
Function *ForwardVarArgsTo) {
2359-
if (CtxProf.contexts().empty())
2359+
if (!CtxProf.isInSpecializedModule())
23602360
return InlineFunction(CB, IFI, MergeAttributes, CalleeAAR, InsertLifetime,
23612361
ForwardVarArgsTo);
23622362

llvm/test/Analysis/CtxProfAnalysis/handle-select.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
; RUN: split-file %s %t
77
; RUN: llvm-ctxprof-util fromYAML --input=%t/profile.yaml --output=%t/profile.ctxprofdata
88
;
9-
; RUN: opt -passes=ctx-instr-gen %t/example.ll -use-ctx-profile=%t/profile.ctxprofdata -S -o - | FileCheck %s --check-prefix=INSTR
10-
; RUN: opt -passes=ctx-instr-gen,module-inline %t/example.ll -use-ctx-profile=%t/profile.ctxprofdata -S -o - | FileCheck %s --check-prefix=POST-INL
11-
; RUN: opt -passes=ctx-instr-gen,module-inline,ctx-prof-flatten %t/example.ll -use-ctx-profile=%t/profile.ctxprofdata -S -o - | FileCheck %s --check-prefix=FLATTEN
9+
; RUN: opt -passes=ctx-instr-gen %t/1234.ll -use-ctx-profile=%t/profile.ctxprofdata -S -o - | FileCheck %s --check-prefix=INSTR
10+
; RUN: opt -passes=ctx-instr-gen,module-inline %t/1234.ll -use-ctx-profile=%t/profile.ctxprofdata -S -o - | FileCheck %s --check-prefix=POST-INL
11+
; RUN: opt -passes=ctx-instr-gen,module-inline,ctx-prof-flatten %t/1234.ll -use-ctx-profile=%t/profile.ctxprofdata -S -o - | FileCheck %s --check-prefix=FLATTEN
1212

1313
; INSTR-LABEL: yes:
1414
; INSTR-NEXT: call void @llvm.instrprof.increment(ptr @foo, i64 [[#]], i32 2, i32 1)
@@ -45,7 +45,7 @@
4545
; entry count of that BB is 4.
4646
; ![[SELPROF]] = !{!"branch_weights", i32 3, i32 1}
4747

48-
;--- example.ll
48+
;--- 1234.ll
4949
define i32 @foo(i32 %t) !guid !0 {
5050
%test = icmp slt i32 %t, 0
5151
br i1 %test, label %yes, label %no

llvm/test/Analysis/CtxProfAnalysis/inline.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
; RUN: split-file %s %t
44
; RUN: llvm-ctxprof-util fromYAML --input=%t/profile.yaml --output=%t/profile.ctxprofdata
55

6-
; RUN: opt -passes='module-inline,print<ctx-prof-analysis>' -ctx-profile-printer-level=everything %t/module.ll -S \
6+
; RUN: opt -passes='module-inline,print<ctx-prof-analysis>' -ctx-profile-printer-level=everything %t/1000.ll -S \
77
; RUN: -use-ctx-profile=%t/profile.ctxprofdata -ctx-profile-printer-level=yaml \
88
; RUN: -o - 2> %t/profile-final.yaml | FileCheck %s
99
; RUN: diff %t/profile-final.yaml %t/expected.yaml
@@ -34,7 +34,7 @@
3434

3535
; Make sure the postlink thinlto pipeline is aware of ctxprof
3636
; RUN: opt -passes='thinlto<O2>' -use-ctx-profile=%t/profile.ctxprofdata \
37-
; RUN: %t/module.ll -S -o - | FileCheck %s --check-prefix=PIPELINE
37+
; RUN: %t/1000.ll -S -o - | FileCheck %s --check-prefix=PIPELINE
3838

3939
; PIPELINE-LABEL: define i32 @entrypoint
4040
; PIPELINE-SAME: !prof ![[ENTRYPOINT_COUNT:[0-9]+]]
@@ -50,7 +50,7 @@
5050
; These are the weights of the un-inlined @a, where the counters were 8, 500 (8 for entry, 500 for loop)
5151
; PIPELINE: ![[LOOP_BW_ORIG]] = !{!"branch_weights", i32 492, i32 8}
5252

53-
;--- module.ll
53+
;--- 1000.ll
5454
define i32 @entrypoint(i32 %x) !guid !0 {
5555
call void @llvm.instrprof.increment(ptr @entrypoint, i64 0, i32 3, i32 0)
5656
%t = icmp eq i32 %x, 0

0 commit comments

Comments
 (0)