forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ctx_prof] "Use" support for pre-thinlink. (llvm#101338)
There is currently no plan to support contextual profiling use in a non- ThinLTO scenario. In the pre-link phase, we only instrument and then immediately bail out to let the linker group functions under an entrypoint in the same module as the entrypoint. We don't actually care what the profile contains - just that we want to use a contextual profile. After that, in post-thinlink, we require the profile be passed again so we can actually use it. The earlier instrumentation will be used to match counter values. While the feature is in development, we add a hidden flag for the use scenario, but we can eventually tie it to the `PGOOptions` mechanism. We will use the same flag in both pre- and post-thinlink, because it simplifies things - usually the post-thinlink args are the same as the ones for pre-. This, despite the flag being basically treated as a boolean in pre-thinlink.
- Loading branch information
1 parent
ae3f57b
commit 9b3f21e
Showing
2 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 | ||
; There is no profile, but that's OK because the prelink does not care about | ||
; the content of the profile, just that we intend to use one. | ||
; There is no scenario currently of doing ctx profile use without thinlto. | ||
; | ||
; RUN: opt -passes='thinlto-pre-link<O2>' -use-ctx-profile=something_that_does_not_exist %s -S | FileCheck %s | ||
|
||
declare void @bar() | ||
|
||
define void @foo(i32 %a, ptr %fct) { | ||
; CHECK-LABEL: define void @foo( | ||
; CHECK-SAME: i32 [[A:%.*]], ptr [[FCT:%.*]]) local_unnamed_addr { | ||
; CHECK-NEXT: [[T:%.*]] = icmp eq i32 [[A]], 0 | ||
; CHECK-NEXT: br i1 [[T]], label %[[YES:.*]], label %[[NO:.*]] | ||
; CHECK: [[YES]]: | ||
; CHECK-NEXT: call void @llvm.instrprof.increment(ptr @__profn_foo, i64 728453322856651412, i32 2, i32 1) | ||
; CHECK-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[FCT]] to i64 | ||
; CHECK-NEXT: call void @llvm.instrprof.value.profile(ptr @__profn_foo, i64 728453322856651412, i64 [[TMP1]], i32 0, i32 0) | ||
; CHECK-NEXT: call void [[FCT]](i32 0) | ||
; CHECK-NEXT: br label %[[EXIT:.*]] | ||
; CHECK: [[NO]]: | ||
; CHECK-NEXT: call void @llvm.instrprof.increment(ptr @__profn_foo, i64 728453322856651412, i32 2, i32 0) | ||
; CHECK-NEXT: call void @bar() | ||
; CHECK-NEXT: br label %[[EXIT]] | ||
; CHECK: [[EXIT]]: | ||
; CHECK-NEXT: ret void | ||
; | ||
%t = icmp eq i32 %a, 0 | ||
br i1 %t, label %yes, label %no | ||
yes: | ||
call void %fct(i32 %a) | ||
br label %exit | ||
no: | ||
call void @bar() | ||
br label %exit | ||
exit: | ||
ret void | ||
} |