Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Profile] Implement new API __llvm_profile_dump
The API is intended to be used by user to do fine grained (per-region) control of profile dumping. Differential Revision: http://reviews.llvm.org/D23106 llvm-svn: 278092
- Loading branch information
Showing
5 changed files
with
120 additions
and
0 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
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
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,62 @@ | ||
/* | ||
RUN: rm -fr %t.profdir | ||
RUN: %clang_profgen=%t.profdir/default_%m.profraw -o %t -O2 %s | ||
RUN: %run %t 2>&1 | FileCheck %s --check-prefix=NO_EXIT_WRITE | ||
RUN: llvm-profdata merge -o %t.profdata %t.profdir | ||
RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s --check-prefix=PROF | ||
NO_EXIT_WRITE: Profile data not written to file: already written | ||
*/ | ||
|
||
int __llvm_profile_dump(void); | ||
void __llvm_profile_reset_counters(void); | ||
int foo(int); | ||
int bar(int); | ||
int skip(int); | ||
|
||
int main(int argc, const char *argv[]) { | ||
int Ret = foo(0); /* region 1 */ | ||
__llvm_profile_dump(); | ||
|
||
/* not profiled -- cleared later. */ | ||
skip(0); /* skipped region */ | ||
|
||
__llvm_profile_reset_counters(); | ||
Ret += bar(0); /* region 2 */ | ||
__llvm_profile_dump(); | ||
|
||
skip(1); | ||
|
||
__llvm_profile_reset_counters(); | ||
/* foo's profile will be merged. */ | ||
foo(1); /* region 3 */ | ||
__llvm_profile_dump(); | ||
|
||
return Ret; | ||
} | ||
|
||
__attribute__((noinline)) int foo(int X) { | ||
/* PROF: define {{.*}} @foo({{.*}}!prof ![[ENT:[0-9]+]] | ||
PROF: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD1:[0-9]+]] | ||
*/ | ||
return X <= 0 ? -X : X; | ||
} | ||
|
||
__attribute__((noinline)) int skip(int X) { | ||
/* PROF: define {{.*}} @skip( | ||
PROF: br i1 %{{.*}}, label %{{.*}}, label %{{[^,]+$}} | ||
*/ | ||
return X <= 0 ? -X : X; | ||
} | ||
|
||
__attribute__((noinline)) int bar(int X) { | ||
/* PROF-LABEL: define {{.*}} @bar( | ||
PROF: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof ![[PD2:[0-9]+]] | ||
*/ | ||
return X <= 0 ? -X : X; | ||
} | ||
|
||
/* | ||
PROF: ![[ENT]] = !{!"function_entry_count", i64 2} | ||
PROF: ![[PD1]] = !{!"branch_weights", i32 2, i32 2} | ||
*/ |