Skip to content

Commit fa7589e

Browse files
Move version check to front
1 parent 55d673d commit fa7589e

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

compiler-rt/lib/profile/InstrProfilingFile.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,17 @@ int __llvm_write_custom_profile(const char *Target,
13851385
return 0;
13861386
}
13871387

1388+
/* Check if there is llvm/runtime version mismatch. */
1389+
if (GET_VERSION(__llvm_profile_get_version()) != INSTR_PROF_RAW_VERSION) {
1390+
PROF_ERR("Runtime and instrumentation version mismatch : "
1391+
"expected %d, but get %d\n",
1392+
INSTR_PROF_RAW_VERSION,
1393+
(int)GET_VERSION(__llvm_profile_get_version()));
1394+
if (PDeathSig == 1)
1395+
lprofRestoreSigKill();
1396+
return -1;
1397+
}
1398+
13881399
/* Get current filename */
13891400
FilenameLength = getCurFilenameLength();
13901401
FilenameBuf = (char *)COMPILER_RT_ALLOCA(FilenameLength + 1);
@@ -1420,17 +1431,6 @@ int __llvm_write_custom_profile(const char *Target,
14201431
BaseSize);
14211432
TargetFilename[FilenameLength + 1 + TargetLength] = 0;
14221433

1423-
/* Check if there is llvm/runtime version mismatch. */
1424-
if (GET_VERSION(__llvm_profile_get_version()) != INSTR_PROF_RAW_VERSION) {
1425-
PROF_ERR("Runtime and instrumentation version mismatch : "
1426-
"expected %d, but get %d\n",
1427-
INSTR_PROF_RAW_VERSION,
1428-
(int)GET_VERSION(__llvm_profile_get_version()));
1429-
if (PDeathSig == 1)
1430-
lprofRestoreSigKill();
1431-
return -1;
1432-
}
1433-
14341434
/* Open and truncate target-specific PGO file */
14351435
FILE *OutputFile = fopen(TargetFilename, "w");
14361436
setProfileFile(OutputFile);

0 commit comments

Comments
 (0)