-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[AIX] PGO codegen changes for function-sections. #139761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mandlebug
wants to merge
4
commits into
llvm:main
Choose a base branch
from
mandlebug:sfertile/AIXPGOFunctionSectionsRenaming
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b39751c
[AIX] PGO codegen changes for function-sections.
mandlebug f8da9c2
Address first round of review comments.
mandlebug d2cac52
Add a new fixed metadata node to carry the xcoff pgo association.
mandlebug e2ba1aa
Address review comments.
mandlebug File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,45 @@ | ||
// RUN: split-file %s %t | ||
// RUN: cd %t | ||
// RUN: %clang_pgogen -ffunction-sections main.c -c -o main.o | ||
// RUN: %clang_pgogen -ffunction-sections needs_gc.c -c -o needs_gc.o | ||
// RUN: %clang_pgogen main.o needs_gc.o -o needs_gc.out | ||
// RUN: env LLVM_PROFILE_FILE=needs_gc.profraw %run ./needs_gc.out > /dev/null | ||
// RUN: llvm-profdata show --all-functions needs_gc.profraw | FileCheck %s | ||
|
||
// CHECK-DAG: main | ||
// CHECK-DAG: baz | ||
// CHECK-DAG: get_message | ||
|
||
//--- main.c | ||
const char* get_message(void) { | ||
return "Hello World!"; | ||
} | ||
|
||
const char* baz(); | ||
|
||
int printf(const char*, ...); | ||
|
||
int main(void) { | ||
printf("%s\n", baz()); | ||
} | ||
|
||
//--- needs_gc.c | ||
extern int not_def_one(const char *); | ||
extern double not_def_two(void); | ||
|
||
extern const char* get_message(void); | ||
|
||
char buf[512]; | ||
int foo(const char *ptr, unsigned long size) { | ||
void *memcpy(void *, const void *, unsigned long); | ||
memcpy(buf, ptr, size); | ||
return not_def_one(buf); | ||
} | ||
|
||
double bar(void) { | ||
return not_def_two(); | ||
} | ||
|
||
const char* baz() { | ||
return get_message(); | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,64 @@ | ||
; RUN: llc --function-sections -mtriple powerpc-ibm-aix-xcoff < %s | \ | ||
; RUN: FileCheck %s | ||
|
||
; RUN: llc --function-sections -mtriple powerpc64-ibm-aix-xcoff < %s | \ | ||
; RUN: FileCheck %s | ||
|
||
@i = external local_unnamed_addr global i32, align 4 | ||
@__llvm_profile_raw_version = weak hidden local_unnamed_addr constant i64 72057594037927944 | ||
@__profc_func1 = private global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", align 8 | ||
@__profd_func1 = private global { i64, i64, i32, ptr, ptr, i32, [4 x i16] } { i64 -2545542355363006406, i64 742261418966908927, i32 sub (i32 ptrtoint (ptr @__profc_func1 to i32), i32 ptrtoint (ptr @__profd_func1 to i32)), ptr @func1.local, ptr null, i32 1, [4 x i16] zeroinitializer }, section "__llvm_prf_data", align 8, !pgo.associated !0 | ||
@__profc_func2 = private global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", align 8 | ||
@__profd_func2 = private global { i64, i64, i32, ptr, ptr, i32, [4 x i16] } { i64 -4377547752858689819, i64 742261418966908927, i32 sub (i32 ptrtoint (ptr @__profc_func2 to i32), i32 ptrtoint (ptr @__profd_func2 to i32)), ptr @func2.local, ptr null, i32 1, [4 x i16] zeroinitializer }, section "__llvm_prf_data", align 8, !pgo.associated !1 | ||
@__llvm_prf_nm = private constant [13 x i8] c"\0B\00func1\01func2", section "__llvm_prf_names", align 1 | ||
@__llvm_profile_filename = weak hidden local_unnamed_addr constant [19 x i8] c"default_%m.profraw\00" | ||
@llvm.used = appending global [3 x ptr] [ptr @__llvm_prf_nm, ptr @__profd_func1, ptr @__profd_func2], section "llvm.metadata" | ||
|
||
@func1.local = private alias i32 (), ptr @func1 | ||
@func2.local = private alias i32 (), ptr @func2 | ||
|
||
define i32 @func1() { | ||
entry: | ||
%pgocount = load i64, ptr @__profc_func1, align 8 | ||
%0 = add i64 %pgocount, 1 | ||
store i64 %0, ptr @__profc_func1, align 8 | ||
%1 = load i32, ptr @i, align 4 | ||
ret i32 %1 | ||
} | ||
|
||
define i32 @func2() { | ||
entry: | ||
%pgocount = load i64, ptr @__profc_func2, align 8 | ||
%0 = add i64 %pgocount, 1 | ||
store i64 %0, ptr @__profc_func2, align 8 | ||
%1 = load i32, ptr @i, align 4 | ||
%call = tail call i32 @external_func(i32 noundef %1) | ||
ret i32 %call | ||
} | ||
|
||
declare i32 @external_func(i32 noundef) | ||
|
||
!0 = !{ptr @__profc_func1} | ||
!1 = !{ptr @__profc_func2} | ||
|
||
; CHECK-DAG: .csect __llvm_prf_cnts.__profc_func1[RW] | ||
; CHECK-DAG: .csect __llvm_prf_data.__profd_func1[RW] | ||
; CHECK-DAG: .csect __llvm_prf_cnts.__profc_func2[RW] | ||
; CHECK-DAG: .csect __llvm_prf_data.__profd_func2[RW] | ||
; CHECK-DAG: .csect __llvm_prf_names[RO] | ||
|
||
; CHECK: .csect __llvm_prf_cnts.__profc_func1[RW] | ||
; CHECK-NEXT: .ref __llvm_prf_names[RO] | ||
; CHECK-NEXT: .ref __llvm_prf_data.__profd_func1[RW] | ||
; CHECK-NEXT: .rename __llvm_prf_cnts.__profc_func1[RW],"__llvm_prf_cnts" | ||
|
||
; CHECK: .csect __llvm_prf_data.__profd_func1[RW] | ||
; CHECK-NEXT: .rename __llvm_prf_data.__profd_func1[RW],"__llvm_prf_data" | ||
|
||
; CHECK: .csect __llvm_prf_cnts.__profc_func2[RW] | ||
; CHECK-NEXT: .ref __llvm_prf_names[RO] | ||
; CHECK-NEXT: .ref __llvm_prf_data.__profd_func2[RW] | ||
; CHECK-NEXT: .rename __llvm_prf_cnts.__profc_func2[RW],"__llvm_prf_cnts" | ||
|
||
; CHECK: .csect __llvm_prf_data.__profd_func2[RW] | ||
; CHECK-NEXT: .rename __llvm_prf_data.__profd_func2[RW],"__llvm_prf_data" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we reduce vertical spacing: use single space in some and no space in others