summaryrefslogtreecommitdiff
path: root/lib/profile/InstrProfilingFile.c
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2016-08-09 04:21:14 +0000
committerXinliang David Li <davidxl@google.com>2016-08-09 04:21:14 +0000
commit662d5497c3a4fbcdbf125d109f4abe5a9385cc20 (patch)
tree75caffb22007df93d6a22f8424a6ee34ffe3e2d0 /lib/profile/InstrProfilingFile.c
parent97809160002d2a275a04e62313e55f1607fde234 (diff)
[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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@278092 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/profile/InstrProfilingFile.c')
-rw-r--r--lib/profile/InstrProfilingFile.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/profile/InstrProfilingFile.c b/lib/profile/InstrProfilingFile.c
index 70953ac2c..70102f324 100644
--- a/lib/profile/InstrProfilingFile.c
+++ b/lib/profile/InstrProfilingFile.c
@@ -522,6 +522,12 @@ int __llvm_profile_write_file(void) {
const char *Filename;
char *FilenameBuf;
+ if (lprofProfileDumped()) {
+ PROF_NOTE("Profile data not written to file: %s.\n",
+ "already written");
+ return 0;
+ }
+
Length = getCurFilenameLength();
FilenameBuf = (char *)COMPILER_RT_ALLOCA(Length + 1);
Filename = getCurFilename(FilenameBuf);
@@ -548,6 +554,18 @@ int __llvm_profile_write_file(void) {
return rc;
}
+COMPILER_RT_VISIBILITY
+int __llvm_profile_dump(void) {
+ if (!doMerging())
+ PROF_WARN("Later invocation of __llvm_profile_dump can lead to clobbering "
+ " of previously dumped profile data : %s. Either use \%m "
+ "in profile name or change profile name before dumping.\n",
+ "online profile merging is not on");
+ int rc = __llvm_profile_write_file();
+ lprofSetProfileDumped();
+ return rc;
+}
+
static void writeFileWithoutReturn(void) { __llvm_profile_write_file(); }
COMPILER_RT_VISIBILITY