[Openmp-commits] [clang] [compiler-rt] [llvm] [openmp] [PGO][Offload] Profile profraw generation for GPU instrumentation #76587 (PR #93365)
Joel E. Denny via Openmp-commits
openmp-commits at lists.llvm.org
Thu Oct 3 15:32:12 PDT 2024
================
@@ -1311,4 +1314,96 @@ COMPILER_RT_VISIBILITY int __llvm_profile_set_file_object(FILE *File,
return 0;
}
+int __llvm_write_custom_profile(const char *Target,
+ const __llvm_profile_data *DataBegin,
+ const __llvm_profile_data *DataEnd,
+ const char *CountersBegin,
+ const char *CountersEnd, const char *NamesBegin,
+ const char *NamesEnd) {
+ int ReturnValue = 0, FilenameLength, TargetLength;
+ char *FilenameBuf, *TargetFilename;
+ const char *Filename;
+
+ /* Save old profile data */
+ FILE *oldFile = getProfileFile();
+
+ // Temporarily suspend getting SIGKILL when the parent exits.
+ int PDeathSig = lprofSuspendSigKill();
+
+ if (lprofProfileDumped() || __llvm_profile_is_continuous_mode_enabled()) {
+ PROF_NOTE("Profile data not written to file: %s.\n", "already written");
+ if (PDeathSig == 1)
+ lprofRestoreSigKill();
+ return 0;
+ }
+
+ /* Get current filename */
+ FilenameLength = getCurFilenameLength();
+ FilenameBuf = (char *)COMPILER_RT_ALLOCA(FilenameLength + 1);
+ Filename = getCurFilename(FilenameBuf, 0);
+
+ /* Check the filename. */
+ if (!Filename) {
+ PROF_ERR("Failed to write file : %s\n", "Filename not set");
+ if (PDeathSig == 1)
+ lprofRestoreSigKill();
+ return -1;
+ }
+
+ /* Allocate new space for our target-specific PGO filename */
+ TargetLength = strlen(Target);
+ TargetFilename =
+ (char *)COMPILER_RT_ALLOCA(FilenameLength + TargetLength + 2);
+
+ /* Prepend "TARGET." to current filename */
----------------
jdenny-ornl wrote:
Can we make this handle file names with directory components? Otherwise, I end up with errors like:
```
LLVM Profile Error: Failed to open file : amdgcn-amd-amdhsa./home/jdenny/tmp/default_15853421304062701701_0.profraw
```
https://github.com/llvm/llvm-project/pull/93365
More information about the Openmp-commits
mailing list