]> granicus.if.org Git - clang/commitdiff
[Perf-training] Fixing an issue with multi-threading PGO generation
authorChris Bieneman <beanz@apple.com>
Tue, 22 Mar 2016 02:55:40 +0000 (02:55 +0000)
committerChris Bieneman <beanz@apple.com>
Tue, 22 Mar 2016 02:55:40 +0000 (02:55 +0000)
When LIT parallelizes the profraw file generation we need to generate unique temp filenames then clean them up after the driver executes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@264021 91177308-0d34-0410-b5e6-96231b3b80d8

utils/perf-training/perf-helper.py

index 19f3819b301ce656fbd2db1b8d4f42918a572385..3fd1c0bb7c98f91e185d8eaf1179057dae5b7b1b 100644 (file)
@@ -16,6 +16,7 @@ import argparse
 import time
 import bisect
 import shlex
+import tempfile
 
 test_env = { 'PATH'    : os.environ['PATH'] }
 
@@ -149,10 +150,12 @@ def cc1(args):
 
   # clear the profile file env, so that we don't generate profdata
   # when capturing the cc1 command
+  handle, profraw_file = tempfile.mkstemp()
+  os.close(handle)
   cc1_env = test_env
-  cc1_env["LLVM_PROFILE_FILE"] = "driver.prfraw"
+  cc1_env["LLVM_PROFILE_FILE"] = profraw_file
   cc1_cmd = get_cc1_command_for_args(cmd, cc1_env)
-  os.remove("driver.prfraw")
+  os.remove(profraw_file)
 
   subprocess.check_call(cc1_cmd)
   return 0;