From 5512fb6275ade520b17cefcb2bc53fbd4be41d5e Mon Sep 17 00:00:00 2001 From: Vsevolod Livinskiy Date: Tue, 8 Jul 2014 12:58:21 +0400 Subject: [PATCH 01/50] alloy.py finds out revision of llvm --- alloy.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/alloy.py b/alloy.py index 1fd9bd14..989058c7 100755 --- a/alloy.py +++ b/alloy.py @@ -296,6 +296,17 @@ def build_ispc(version_LLVM, make): p_temp = os.getenv("PATH") os.environ["PATH"] = os.environ["LLVM_HOME"] + "/bin-" + version_LLVM + "/bin:" + os.environ["PATH"] try_do_LLVM("clean ISPC for building", "make clean", True) + folder = os.environ["LLVM_HOME"] + os.sep + "llvm-" + if options.folder == "": + folder += version_LLVM + if options.debug == True: + folder += "dbg" + + p = subprocess.Popen("svnversion " + folder, shell=True, \ + stdout=subprocess.PIPE, stderr=subprocess.PIPE) + (revision_llvm, err) = p.communicate() + + try_do_LLVM("recognize LLVM revision", "svn info " + folder, True) try_do_LLVM("build ISPC with LLVM version " + version_LLVM + " ", make, True) os.environ["PATH"] = p_temp else: @@ -703,6 +714,7 @@ import smtplib import datetime import copy import multiprocessing +import subprocess from email.MIMEMultipart import MIMEMultipart from email.MIMEBase import MIMEBase from email.mime.text import MIMEText From 97057ed7a1bf286a790290a1c80a2dd98f422874 Mon Sep 17 00:00:00 2001 From: Vsevolod Livinskiy Date: Tue, 8 Jul 2014 15:51:14 +0400 Subject: [PATCH 02/50] Send mail with build error. --- alloy.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/alloy.py b/alloy.py index 989058c7..f4c1c411 100755 --- a/alloy.py +++ b/alloy.py @@ -72,6 +72,9 @@ def try_do_LLVM(text, command, from_validation): postfix = " >> " + alloy_build + " 2>> " + alloy_build if os.system(command + postfix) != 0: print_debug("ERROR.\n", from_validation, alloy_build) + send_mail("ISPC test system download/build fail", "ISPC_test_system", options.notify,\ + "Unable to build or download something. See logs for more information.", \ + alloy_build, "alloy_build.log") error("can't " + text, 1) print_debug("DONE.\n", from_validation, alloy_build) @@ -296,6 +299,7 @@ def build_ispc(version_LLVM, make): p_temp = os.getenv("PATH") os.environ["PATH"] = os.environ["LLVM_HOME"] + "/bin-" + version_LLVM + "/bin:" + os.environ["PATH"] try_do_LLVM("clean ISPC for building", "make clean", True) + folder = os.environ["LLVM_HOME"] + os.sep + "llvm-" if options.folder == "": folder += version_LLVM @@ -630,6 +634,20 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, s.sendmail('ISPC_test_system', name, msg.as_string()) s.quit() +def send_mail(subject, _from, to, line, attach_filename, attach_name): + smtp_server = os.environ["SMTP_ISPC"] + msg = MIMEMultipart() + msg['Subject'] = subject + msg['From'] = _from + msg['To'] = to + text = MIMEText(line, "", "KOI-8") + msg.attach(text) + attach_mail_file(msg, attach_filename, attach_name) + s = smtplib.SMTP(smtp_server) + for name in options.notify.split(" "): + s.sendmail(_from, name, msg.as_string()) + s.quit() + def Main(): global current_OS global current_OS_version From d890ccc92cb93a9eee169a5cfc03a4e04b66690f Mon Sep 17 00:00:00 2001 From: Vsevolod Livinskiy Date: Tue, 8 Jul 2014 16:56:15 +0400 Subject: [PATCH 03/50] Unique way to send e-mail --- alloy.py | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/alloy.py b/alloy.py index f4c1c411..ad08fed8 100755 --- a/alloy.py +++ b/alloy.py @@ -72,9 +72,11 @@ def try_do_LLVM(text, command, from_validation): postfix = " >> " + alloy_build + " 2>> " + alloy_build if os.system(command + postfix) != 0: print_debug("ERROR.\n", from_validation, alloy_build) - send_mail("ISPC test system download/build fail", "ISPC_test_system", options.notify,\ - "Unable to build or download something. See logs for more information.", \ - alloy_build, "alloy_build.log") + if options.notify != "": + msg = MIMEMultipart() + attach_mail_file(msg, alloy_build, "alloy_build.log") + send_mail("ISPC test system download/build fail", "ISPC_test_system", options.notify,\ + "Unable to build or download something. See logs for more information.", msg) error("can't " + text, 1) print_debug("DONE.\n", from_validation, alloy_build) @@ -375,11 +377,7 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, os.environ["PATH"] = os.environ["ISPC_HOME"] + ":" + os.environ["PATH"] if options.notify != "": common.remove_if_exists(os.environ["ISPC_HOME"] + os.sep + "notify_log.log") - smtp_server = os.environ["SMTP_ISPC"] msg = MIMEMultipart() - msg['Subject'] = 'ISPC test system results' - msg['From'] = 'ISPC_test_system' - msg['To'] = options.notify print_debug("Command: " + ' '.join(sys.argv) + "\n", False, "") print_debug("Folder: " + os.environ["ISPC_HOME"] + "\n", False, "") date = datetime.datetime.now() @@ -623,29 +621,18 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, for i in range(0,len(f_lines)): line = line + f_lines[i][:-1] line = line + ' \n' - text = MIMEText(line, "", "KOI-8") - msg.attach(text) attach_mail_file(msg, alloy_build, "alloy_build.log") - s = smtplib.SMTP(smtp_server) + send_mail("ISPC test system results", "ISPC_test_system", options.notify, line, msg) - print "Sending an e-mail with logs:", options.notify - for name in options.notify.split(" "): - print "Sending to: ", name - s.sendmail('ISPC_test_system', name, msg.as_string()) - s.quit() - -def send_mail(subject, _from, to, line, attach_filename, attach_name): +def send_mail(subject, from_field, to, line, msg): smtp_server = os.environ["SMTP_ISPC"] - msg = MIMEMultipart() msg['Subject'] = subject - msg['From'] = _from + msg['From'] = from_field msg['To'] = to text = MIMEText(line, "", "KOI-8") msg.attach(text) - attach_mail_file(msg, attach_filename, attach_name) s = smtplib.SMTP(smtp_server) - for name in options.notify.split(" "): - s.sendmail(_from, name, msg.as_string()) + s.sendmail(from_field, options.notify.split(" "), msg.as_string()) s.quit() def Main(): From 7ecc9e07698aee00628534c364e4eaccc3ff1560 Mon Sep 17 00:00:00 2001 From: Vsevolod Livinskiy Date: Tue, 8 Jul 2014 18:03:01 +0400 Subject: [PATCH 04/50] Some fixes in send function --- alloy.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/alloy.py b/alloy.py index ad08fed8..8bed9381 100755 --- a/alloy.py +++ b/alloy.py @@ -75,8 +75,7 @@ def try_do_LLVM(text, command, from_validation): if options.notify != "": msg = MIMEMultipart() attach_mail_file(msg, alloy_build, "alloy_build.log") - send_mail("ISPC test system download/build fail", "ISPC_test_system", options.notify,\ - "Unable to build or download something. See logs for more information.", msg) + send_mail("Unable to build or download something. See logs for more information.", msg) error("can't " + text, 1) print_debug("DONE.\n", from_validation, alloy_build) @@ -615,24 +614,24 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, fp = open(os.environ["ISPC_HOME"] + os.sep + "notify_log.log", 'rb') f_lines = fp.readlines() fp.close() - line = "" + body = "" if not sys.exc_info()[0] == None: - line = line + "Last exception: " + str(sys.exc_info()) + '\n' + body = body + "Last exception: " + str(sys.exc_info()) + '\n' for i in range(0,len(f_lines)): - line = line + f_lines[i][:-1] - line = line + ' \n' + body = body + f_lines[i][:-1] + body = body + ' \n' attach_mail_file(msg, alloy_build, "alloy_build.log") - send_mail("ISPC test system results", "ISPC_test_system", options.notify, line, msg) + send_mail(body, msg) -def send_mail(subject, from_field, to, line, msg): +def send_mail(body, msg): smtp_server = os.environ["SMTP_ISPC"] - msg['Subject'] = subject - msg['From'] = from_field - msg['To'] = to - text = MIMEText(line, "", "KOI-8") + msg['Subject'] = "ISPC test system results" + msg['From'] = "ISPC_test_system" + msg['To'] = options.notify + text = MIMEText(body, "", "KOI-8") msg.attach(text) s = smtplib.SMTP(smtp_server) - s.sendmail(from_field, options.notify.split(" "), msg.as_string()) + s.sendmail(options.notify, options.notify.split(" "), msg.as_string()) s.quit() def Main(): From 8b107ad67a36fe65c5952b5e23f39054d7de24db Mon Sep 17 00:00:00 2001 From: Vsevolod Livinskiy Date: Wed, 9 Jul 2014 23:19:27 +0400 Subject: [PATCH 05/50] Fix for trunk 212388+ --- module.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/module.cpp b/module.cpp index b532c4ac..b5fd860c 100644 --- a/module.cpp +++ b/module.cpp @@ -2004,19 +2004,33 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre #endif inst.setDiagnostics(diagEngine); +#if defined(LLVM_3_1) || defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) clang::TargetOptions &options = inst.getTargetOpts(); +#else // LLVM 3.5+ + const std::shared_ptr< clang::TargetOptions > &options = + std::make_shared< clang::TargetOptions >(inst.getTargetOpts()); +#endif + llvm::Triple triple(module->getTargetTriple()); if (triple.getTriple().empty()) { triple.setTriple(llvm::sys::getDefaultTargetTriple()); } + +#if defined(LLVM_3_1) || defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) options.Triple = triple.getTriple(); +#else // LLVM 3.5+ + options->Triple = triple.getTriple(); +#endif #if defined(LLVM_3_1) || defined(LLVM_3_2) clang::TargetInfo *target = clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), options); -#else // LLVM 3.3+ +#elif defined(LLVM_3_3) || defined(LLVM_3_4) clang::TargetInfo *target = clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), &options); +#else // LLVM 3.5+ + clang::TargetInfo *target = + clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), options); #endif inst.setTarget(target); From d049746585209fe216882c40f4ed0205a06cece4 Mon Sep 17 00:00:00 2001 From: jbrodman Date: Thu, 10 Jul 2014 03:11:46 -0700 Subject: [PATCH 06/50] Add proper cast to eliminate size mismatch warning --- examples/tasksys.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tasksys.cpp b/examples/tasksys.cpp index d7b2a801..45be7605 100644 --- a/examples/tasksys.cpp +++ b/examples/tasksys.cpp @@ -745,7 +745,7 @@ InitTaskSystem() { threads = (pthread_t *)malloc(nThreads * sizeof(pthread_t)); for (int i = 0; i < nThreads; ++i) { - err = pthread_create(&threads[i], NULL, &lTaskEntry, (void *)(i)); + err = pthread_create(&threads[i], NULL, &lTaskEntry, (void *)((long long)i)); if (err != 0) { fprintf(stderr, "Error creating pthread %d: %s\n", i, strerror(err)); exit(1); From d56d690d7792ca7729b1b15dbfcff45f3fc4f99e Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Fri, 11 Jul 2014 18:25:33 +0400 Subject: [PATCH 07/50] Fixed Makefile target gcc to use g++ instead of clang --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e6e742a3..29b5875e 100644 --- a/Makefile +++ b/Makefile @@ -240,9 +240,9 @@ ispc: print_llvm_src dirs $(OBJS) clang: ispc clang: CXX=clang++ -# Use gcc as a default compiler, instead of gcc +# Use gcc as a default compiler gcc: ispc -gcc: CXX=clang++ +gcc: CXX=g++ # Build ispc with address sanitizer instrumentation using clang compiler # Note that this is not portable build From 7cde453e36beb46900c37dc3801e3b0fbd78ed89 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Mon, 14 Jul 2014 16:06:59 +0400 Subject: [PATCH 08/50] add 'tail' capability to 'attach_mail_file' function, shortened 'alloy_build_log.log' being sent to 100 lines in case of success and 400 in case of failure --- alloy.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/alloy.py b/alloy.py index 8bed9381..40f0e2d3 100755 --- a/alloy.py +++ b/alloy.py @@ -33,9 +33,22 @@ # // Author: Filippov Ilia -def attach_mail_file(msg, filename, name): +def tail_and_save(file_in, file_out, tail = 100): + with open(file_in, 'r') as f_in: + lines = f_in.readlines()[-tail:] + + with open(file_out, 'w') as f_out: + f_out.writelines(lines) + + +def attach_mail_file(msg, filename, name, tail = -1): if os.path.exists(filename): - fp = open(filename, "rb") + if tail > 0: + tail_and_save(filename, filename + '.tail', tail) + fp = open(filename + '.tail', "rb") + else: + fp = open(filename, "rb") + to_attach = MIMEBase("application", "octet-stream") to_attach.set_payload(fp.read()) encode_base64(to_attach) @@ -43,6 +56,7 @@ def attach_mail_file(msg, filename, name): fp.close() msg.attach(to_attach) + def setting_paths(llvm, ispc, sde): if llvm != "": os.environ["LLVM_HOME"]=llvm @@ -74,8 +88,10 @@ def try_do_LLVM(text, command, from_validation): print_debug("ERROR.\n", from_validation, alloy_build) if options.notify != "": msg = MIMEMultipart() - attach_mail_file(msg, alloy_build, "alloy_build.log") - send_mail("Unable to build or download something. See logs for more information.", msg) + attach_mail_file(msg, alloy_build, "alloy_build.log", 400) + attach_mail_file(msg, stability_log, "stability.log") + attach_mail_file(msg, stability.in_file, "run_tests_log.log") + send_mail("Error while executing " + command + ". Examine logs for more information.", msg) error("can't " + text, 1) print_debug("DONE.\n", from_validation, alloy_build) @@ -620,7 +636,7 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, for i in range(0,len(f_lines)): body = body + f_lines[i][:-1] body = body + ' \n' - attach_mail_file(msg, alloy_build, "alloy_build.log") + attach_mail_file(msg, alloy_build, "alloy_build.log", 100) send_mail(body, msg) def send_mail(body, msg): From ff2f3c896f4b91761d58a1b686d6c3815aa06153 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Mon, 14 Jul 2014 16:18:07 +0400 Subject: [PATCH 09/50] add an alloy.py option to build ispc binary with g++ --- alloy.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/alloy.py b/alloy.py index 8bed9381..3809ec58 100755 --- a/alloy.py +++ b/alloy.py @@ -239,7 +239,7 @@ def check_targets(): answer_sde = [] # check what native targets do we have if current_OS != "Windows": - try_do_LLVM("build check_ISA", "clang check_isa.cpp -o check_isa.exe", True) + try_do_LLVM("build check_ISA", "g++ check_isa.cpp -o check_isa.exe", True) else: try_do_LLVM("build check_ISA", "cl check_isa.cpp", True) SSE2 = ["sse2-i32x4", "sse2-i32x8"] @@ -296,6 +296,18 @@ def check_targets(): def build_ispc(version_LLVM, make): current_path = os.getcwd() os.chdir(os.environ["ISPC_HOME"]) + + # the default 'make' variable for ISPC and LLVM may be actually different, + # so we have to manually set a new make command here (make targets are already verified in Main() ) + if (options.ispc_compiler == "clang"): + make_target = "clang" + elif (options.ispc_compiler == "gcc"): + make_target = "gcc" + elif (options.ispc_compiler == "g++"): + make_target = "gcc" + + make_ispc = "make " + make_target + " -j" + options.speed + if current_OS != "Windows": p_temp = os.getenv("PATH") os.environ["PATH"] = os.environ["LLVM_HOME"] + "/bin-" + version_LLVM + "/bin:" + os.environ["PATH"] @@ -312,7 +324,7 @@ def build_ispc(version_LLVM, make): (revision_llvm, err) = p.communicate() try_do_LLVM("recognize LLVM revision", "svn info " + folder, True) - try_do_LLVM("build ISPC with LLVM version " + version_LLVM + " ", make, True) + try_do_LLVM("build ISPC with LLVM version " + version_LLVM + " ", make_ispc, True) os.environ["PATH"] = p_temp else: p_temp = os.getenv("LLVM_INSTALL_DIR") @@ -650,6 +662,19 @@ def Main(): parser.print_help() exit(0) + # set appropriate makefile target + # gcc and g++ options are equal and added for ease of use + if (options.ispc_compiler == "clang"): + make_target = "clang" + elif (options.ispc_compiler == "gcc"): + make_target = "gcc" + elif (options.ispc_compiler == "g++"): + make_target = "gcc" + else: + error("unknow option for --ispc-compiler: " + options.ispc_compiler, 1) + parser.print_help() + exit(0) + setting_paths(options.llvm_home, options.ispc_home, options.sde_home) if os.environ.get("LLVM_HOME") == None: error("you have no LLVM_HOME", 1) @@ -759,6 +784,8 @@ if __name__ == '__main__': help='ask for validation run', default=False, action="store_true") parser.add_option('-j', dest='speed', help='set -j for make', default=num_threads) + parser.add_option('--ispc-compiler', dest='ispc_compiler', + help='set compiler to build ispc binary (clang or g++)', default="clang") # options for activity "build LLVM" llvm_group = OptionGroup(parser, "Options for building LLVM", "These options must be used with -b option.") From 1cd5d72be45d171d78c885b3f250a2f0ee27b74b Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Mon, 14 Jul 2014 17:31:06 +0400 Subject: [PATCH 10/50] removed a bug --- alloy.py | 1 - 1 file changed, 1 deletion(-) diff --git a/alloy.py b/alloy.py index 40f0e2d3..5efd75e0 100755 --- a/alloy.py +++ b/alloy.py @@ -90,7 +90,6 @@ def try_do_LLVM(text, command, from_validation): msg = MIMEMultipart() attach_mail_file(msg, alloy_build, "alloy_build.log", 400) attach_mail_file(msg, stability_log, "stability.log") - attach_mail_file(msg, stability.in_file, "run_tests_log.log") send_mail("Error while executing " + command + ". Examine logs for more information.", msg) error("can't " + text, 1) print_debug("DONE.\n", from_validation, alloy_build) From ad67e3bb5d646acc9689bdf1f5b99353a6df6580 Mon Sep 17 00:00:00 2001 From: Dmitry Babokin Date: Mon, 14 Jul 2014 18:49:35 +0400 Subject: [PATCH 11/50] Moving 3.4 build to LLVM 3.4.2 release. --- alloy.py | 2 +- ...as-gather.patch => 3point4point0_r201126-alias-gather.patch} | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) rename llvm_patches/{3_4_r201126-alias-gather.patch => 3point4point0_r201126-alias-gather.patch} (97%) diff --git a/alloy.py b/alloy.py index 8bed9381..0a8f20d5 100755 --- a/alloy.py +++ b/alloy.py @@ -97,7 +97,7 @@ def build_LLVM(version_LLVM, revision, folder, tarball, debug, selfbuild, extra, if version_LLVM == "trunk": SVN_PATH="trunk" if version_LLVM == "3.4": - SVN_PATH="tags/RELEASE_34/final" + SVN_PATH="tags/RELEASE_34/dot2-final" version_LLVM = "3_4" if version_LLVM == "3.3": SVN_PATH="tags/RELEASE_33/final" diff --git a/llvm_patches/3_4_r201126-alias-gather.patch b/llvm_patches/3point4point0_r201126-alias-gather.patch similarity index 97% rename from llvm_patches/3_4_r201126-alias-gather.patch rename to llvm_patches/3point4point0_r201126-alias-gather.patch index 9cebc3f6..d7e9c1f7 100644 --- a/llvm_patches/3_4_r201126-alias-gather.patch +++ b/llvm_patches/3point4point0_r201126-alias-gather.patch @@ -1,3 +1,5 @@ +# This patch needs to be applied only to 3.4 (not 3.4.2), so this has the name, +# which doesn't trigger automatic application of the patch (no 3_4 in the name). Index: include/llvm/IR/IntrinsicsX86.td =================================================================== --- include/llvm/IR/IntrinsicsX86.td (revision 201125) From 1461b09b5f411c1f1a4d678149e781dd40666c08 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Mon, 14 Jul 2014 22:04:03 +0400 Subject: [PATCH 12/50] '--ispc_compiler' changed to '--ispc_build_compiler', 'check_isa.cpp' now compiles with '--ispc_build_compiler' (g++ or clang), removed code duplication --- alloy.py | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/alloy.py b/alloy.py index 3809ec58..068531c6 100755 --- a/alloy.py +++ b/alloy.py @@ -33,6 +33,7 @@ # // Author: Filippov Ilia + def attach_mail_file(msg, filename, name): if os.path.exists(filename): fp = open(filename, "rb") @@ -239,7 +240,12 @@ def check_targets(): answer_sde = [] # check what native targets do we have if current_OS != "Windows": - try_do_LLVM("build check_ISA", "g++ check_isa.cpp -o check_isa.exe", True) + if options.ispc_build_compiler == "clang": + cisa_compiler = "clang" + elif options.ispc_build_compiler == "gcc": + cisa_compiler = "g++" + + try_do_LLVM("build check_ISA", cisa_compiler + " check_isa.cpp -o check_isa.exe", True) else: try_do_LLVM("build check_ISA", "cl check_isa.cpp", True) SSE2 = ["sse2-i32x4", "sse2-i32x8"] @@ -297,16 +303,7 @@ def build_ispc(version_LLVM, make): current_path = os.getcwd() os.chdir(os.environ["ISPC_HOME"]) - # the default 'make' variable for ISPC and LLVM may be actually different, - # so we have to manually set a new make command here (make targets are already verified in Main() ) - if (options.ispc_compiler == "clang"): - make_target = "clang" - elif (options.ispc_compiler == "gcc"): - make_target = "gcc" - elif (options.ispc_compiler == "g++"): - make_target = "gcc" - - make_ispc = "make " + make_target + " -j" + options.speed + make_ispc = "make " + options.ispc_build_compiler + " -j" + options.speed if current_OS != "Windows": p_temp = os.getenv("PATH") @@ -664,14 +661,9 @@ def Main(): # set appropriate makefile target # gcc and g++ options are equal and added for ease of use - if (options.ispc_compiler == "clang"): - make_target = "clang" - elif (options.ispc_compiler == "gcc"): - make_target = "gcc" - elif (options.ispc_compiler == "g++"): - make_target = "gcc" - else: - error("unknow option for --ispc-compiler: " + options.ispc_compiler, 1) + if options.ispc_build_compiler != "clang" and \ + options.ispc_build_compiler != "gcc": + error("unknow option for --ispc-compiler: " + options.ispc_build_compiler, 1) parser.print_help() exit(0) @@ -784,8 +776,8 @@ if __name__ == '__main__': help='ask for validation run', default=False, action="store_true") parser.add_option('-j', dest='speed', help='set -j for make', default=num_threads) - parser.add_option('--ispc-compiler', dest='ispc_compiler', - help='set compiler to build ispc binary (clang or g++)', default="clang") + parser.add_option('--ispc-build-compiler', dest='ispc_build_compiler', + help='set compiler to build ispc binary (clang/gcc)', default="clang") # options for activity "build LLVM" llvm_group = OptionGroup(parser, "Options for building LLVM", "These options must be used with -b option.") From 21cb6094233d6d90fc11df26709a08c392781a24 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Wed, 16 Jul 2014 15:12:39 +0400 Subject: [PATCH 13/50] changed 'ispc-compiler' to 'ispc-build-compiler' in error message --- alloy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alloy.py b/alloy.py index 0d096950..8bd26d6c 100755 --- a/alloy.py +++ b/alloy.py @@ -677,7 +677,7 @@ def Main(): # gcc and g++ options are equal and added for ease of use if options.ispc_build_compiler != "clang" and \ options.ispc_build_compiler != "gcc": - error("unknow option for --ispc-compiler: " + options.ispc_build_compiler, 1) + error("unknow option for --ispc-build-compiler: " + options.ispc_build_compiler, 1) parser.print_help() exit(0) From fd253d5e912eaa8cadab442c0c8726d4baf5ef84 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Thu, 17 Jul 2014 15:38:58 +0400 Subject: [PATCH 14/50] updated fail_db.txt for knc target --- fail_db.txt | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/fail_db.txt b/fail_db.txt index dd0fbdcf..e45578d1 100644 --- a/fail_db.txt +++ b/fail_db.txt @@ -266,3 +266,73 @@ ./tests/ptr-22.ispc runfail x86-64 generic-16 Linux LLVM 3.4 clang++3.4 -O0 * ./tests/ptr-22.ispc runfail x86-64 generic-4 Linux LLVM 3.5 clang++3.4 -O0 * ./tests/ptr-22.ispc runfail x86-64 generic-16 Linux LLVM 3.5 clang++3.4 -O0 * +./tests/ptr-assign-lhs-math-1.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O2 * +./tests/ptr-22.ispc runfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/atomics-1.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/atomics-10.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/atomics-11.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/atomics-12.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/atomics-13.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/atomics-14.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/atomics-2.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/atomics-3.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/atomics-4.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/atomics-9.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/exclusive-scan-add-1.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/exclusive-scan-add-10.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/exclusive-scan-add-8.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/exclusive-scan-add-9.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/exclusive-scan-and-1.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/exclusive-scan-and-2.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/exclusive-scan-or-1.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/reduce-equal-1.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/reduce-equal-10.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/reduce-equal-12.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/reduce-equal-13.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/reduce-equal-2.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/reduce-equal-3.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/reduce-equal-4.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/reduce-equal-5.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/reduce-equal-6.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/reduce-equal-8.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * +./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 * +./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 * +./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 * +./tests/paddus_vi16.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 * +./tests/paddus_vi8.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 * +./tests/pmuls_i64.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 * +./tests/pmulus_i16.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 * +./tests/pmulus_i32.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 * +./tests/pmulus_i64.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 * +./tests/pmulus_i8.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 * +./tests/ptr-assign-lhs-math-1.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 * +./tests/atomics-1.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/atomics-10.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/atomics-11.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/atomics-12.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/atomics-13.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/atomics-14.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/atomics-2.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/atomics-3.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/atomics-4.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/atomics-9.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/exclusive-scan-add-1.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/exclusive-scan-add-10.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/exclusive-scan-add-8.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/exclusive-scan-add-9.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/exclusive-scan-and-1.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/exclusive-scan-and-2.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/exclusive-scan-or-1.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/reduce-equal-1.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/reduce-equal-10.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/reduce-equal-12.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/reduce-equal-13.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/reduce-equal-2.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/reduce-equal-3.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/reduce-equal-4.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/reduce-equal-5.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/reduce-equal-6.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/reduce-equal-8.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * From 9dd1d67a394d3ec33f002b22daebc5e2aec9a9bf Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Fri, 18 Jul 2014 19:34:34 +0400 Subject: [PATCH 15/50] pass g++ as a compiler to run_tests.py when ispc_build_compiler==gcc --- alloy.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/alloy.py b/alloy.py index 8bd26d6c..abe0969c 100755 --- a/alloy.py +++ b/alloy.py @@ -438,6 +438,9 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, LLVM = [] targets = [] sde_targets = [] +# sometimes clang++ is not avaluable. if --ispc-build-compiler = gcc we will pass in g++ compiler + if options.ispc_build_compiler == "gcc": + stability.compiler_exe = "g++" # parsing option only, update parameters of run if "-O2" in only: opts.append(False) From 7c3a2435b3726d49d0bddf2bcdd7569bebe71c11 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Sat, 19 Jul 2014 14:49:49 +0400 Subject: [PATCH 16/50] passing icpc compiler for knc target --- alloy.py | 12 +++++++++--- run_tests.py | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/alloy.py b/alloy.py index abe0969c..809c3f76 100755 --- a/alloy.py +++ b/alloy.py @@ -438,9 +438,7 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, LLVM = [] targets = [] sde_targets = [] -# sometimes clang++ is not avaluable. if --ispc-build-compiler = gcc we will pass in g++ compiler - if options.ispc_build_compiler == "gcc": - stability.compiler_exe = "g++" + # parsing option only, update parameters of run if "-O2" in only: opts.append(False) @@ -521,6 +519,14 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, for j in range(0,len(targets)): stability.target = targets[j] stability.wrapexe = "" + # choosing right compiler for a given target + # sometimes clang++ is not avaluable. if --ispc-build-compiler = gcc we will pass in g++ compiler + if options.ispc_build_compiler == "gcc": + stability.compiler_exe = "g++" + # but 'knc' target is supported only by icpc, so set explicitly + if "knc" in targets[j]: + stability.compiler_exe = "icpc" + # now set archs for targets if "generic" in targets[j]: arch = gen_archs elif "knc" in targets[j]: diff --git a/run_tests.py b/run_tests.py index c9d8f2ff..b5bc2bb0 100755 --- a/run_tests.py +++ b/run_tests.py @@ -589,7 +589,7 @@ def run_tests(options1, args, print_version): options.compiler_exe = "cl.exe" else: options.compiler_exe = "clang++" - + # checks the required compiler otherwise prints an error message PATH_dir = string.split(os.getenv("PATH"), os.pathsep) compiler_exists = False From 09ec2db6e9f1570e22aec99674daf50626729361 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Sun, 20 Jul 2014 13:21:05 +0400 Subject: [PATCH 17/50] add advanced test completion logging --- alloy.py | 5 +- common.py | 33 ++-- regression.py | 376 +++++++++++++++++++++++++++++++++++++++++++++ regression_read.py | 70 +++++++++ run_tests.py | 45 ++++-- 5 files changed, 509 insertions(+), 20 deletions(-) create mode 100644 regression.py create mode 100755 regression_read.py diff --git a/alloy.py b/alloy.py index 8bd26d6c..f5f45292 100755 --- a/alloy.py +++ b/alloy.py @@ -631,7 +631,8 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, if options.notify != "": attach_mail_file(msg, performance.in_file, "performance.log") attach_mail_file(msg, "." + os.sep + "logs" + os.sep + "perf_build.log", "perf_build.log") - +# dumping gathered info to the file + commom.ex_state.dump(alloy_folder + "test_table.dump", commom.ex_state.tt) # sending e-mail with results if options.notify != "": fp = open(os.environ["ISPC_HOME"] + os.sep + "notify_log.log", 'rb') @@ -702,6 +703,8 @@ def Main(): f_date = "logs" common.remove_if_exists(f_date) os.makedirs(f_date) + global alloy_folder + alloy_folder = os.getcwd() + os.sep + f_date + os.sep global alloy_build alloy_build = os.getcwd() + os.sep + f_date + os.sep + "alloy_build.log" global stability_log diff --git a/common.py b/common.py index 9fe611f0..0fda9b45 100755 --- a/common.py +++ b/common.py @@ -36,23 +36,36 @@ import sys import os import errno import shutil -class ExecutionStatGatherer: - def __init__(self): - optimizations = ['O0', 'O2'] - architectures = ['x86', 'x86-64'] - all_est_targets = ['sse2-i32x4', 'sse2-i32x8', 'sse4-i32x4', 'sse4-i32x8', 'sse4-i16x8', - 'sse4-i8x16', 'avx1-i32x8', 'avx1-i32x16', 'avx1.1-i32x8', - 'avx1.1-i32x16', 'avx2-i32x8', 'avx2-i32x16', 'generic-x1', - 'generic-x4', 'generic-x8', 'generic-x16', 'generic-x32', - 'generic-x64', 'knc'] +from regression import * +# this class instance is intended to gather and store all information +# regarding the testing process. Defined in 'regression.py' +ex_state = ExecutionStateGatherer() + +# load/save almost every object to a file (good for bug reproducing) +def dump(fname, obj): + import pickle + with open(fname, 'w') as fp: + pickle.dump(obj, fp) + +def undump(fname): + import pickle + with open(fname, 'r') as fp: + obj = pickle.load(fp) + return obj + +# retrieve the host name +def get_host_name(): + import socket + return socket.gethostname() + def write_to_file(filename, line): f = open(filename, 'a') f.writelines(line) f.close() -#remove file if it exists +# remove file if it exists def remove_if_exists(filename): if os.path.exists(filename): if os.path.isdir(filename): diff --git a/regression.py b/regression.py new file mode 100644 index 00000000..6ce0c532 --- /dev/null +++ b/regression.py @@ -0,0 +1,376 @@ +#!/usr/bin/python +# +# Copyright (c) 2014, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# // Authors: Anton Mitrokhin, Vsevolod Livinskiy + +class TestResult(object): + """ + this class stores basicly two integers which stand for the result + of the test: (runfail{0/1}, compfail{0/1}). other values are + deemed invalid. the __cmp__ function of this class is used to + define what test regression actually is. + """ + def __init__(self, runfailed, compfailed): + self.runfailed, self.compfailed = (runfailed, compfailed) + + def __cmp__(self, other): + if isinstance(other, TestResult): + if self.runfailed == other.runfailed and \ + self.compfailed == other.compfailed: + return 0 + elif self.compfailed > other.compfailed: + return 1 + elif self.runfailed > other.runfailed and \ + self.compfailed == other.compfailed: + return 1 + else: + return -1 + + raise RuntimeError("Wrong type for comparioson") + return NotImplemented + + def __repr__(self): + if (self.runfailed < 0 or self.compfailed < 0): + return "(Undefined)" + return "(r%d c%d)" % (self.runfailed, self.compfailed) + + +class TestCase(object): + """ + the TestCase() is a combination of parameters the tast was run with: + the architecture (x86, x86-64 ...), compiler optimization (-O0, -O2 ...) + and target (sse, avx ...). we also store the result of the test here. + """ + def __init__(self, arch, opt, target): + self.arch, self.opt, self.target = (arch, opt, target) + self.result = TestResult(-1, -1) + + def __repr__(self): + string = "%s %s %s: " % (self.arch, self.opt, self.target) + string = string + repr(self.result) + '\n' + return string + + def __hash__(self): + return hash(self.arch + self.opt + self.target) + + def __ne__(self, other): + if isinstance(other, TestCase): + if hash(self.arch + self.opt + self.target) != hash(other): + return True + return False + raise RuntimeError("Wrong type for comparioson") + return NotImplemented + + def __eq__(self, other): + if isinstance(other, TestCase): + return not self.__ne__(other) + raise RuntimeError("Wrong type for comparioson") + return NotImplemented + + +class Test(object): + """ + Test() stores all TestCase() objects for a given test file name + i.e. all archs/opts/targets/ and corresponding testing results. + """ + def __init__(self, name): + self.name = name + self.test_cases = [] + + def add_result(self, test_case): + if test_case in self.test_cases: + raise RuntimeError("This test case is already in the list: " + repr(test_case)) + return + self.test_cases.append(test_case) + + def __repr__(self): + string = self.name + '\n' + string = string.rjust(20) + for test_case in self.test_cases: + string += repr(test_case).rjust(60) + '\n' + return string + + def __hash__(self): + return hash(self.name) + + def __ne__(self, other): + if isinstance(other, Test): + if hash(self) != hash(other): + return True + return False + return NotImplemented + + def __eq__(self, other): + if isinstance(other, Test): + return not self.__ne__(other) + return NotImplemented + + +class RegressionInfo(object): + """ + service class which provides some statistics on a given regression. + the regression test names and cases are given in a form of Test() objects + with empty (-1, -1) results + """ + def __init__(self, revision_old, revision_new, tests): + self.revision_old, self.revision_new = (revision_old, revision_new) + self.tests = tests + self.archfailes = {} + self.optfails = {} + self.targetfails = {} + self.testfails = {} + self.archs = [] + self.opts = [] + self.targets = [] + + for test in tests: + for test_case in test.test_cases: + self.inc_dictionary(self.testfails, test.name) + self.inc_dictionary(self.archfailes, test_case.arch) + self.inc_dictionary(self.optfails, test_case.opt) + self.inc_dictionary(self.targetfails, test_case.target) + + self.archs = self.archfailes.keys() + self.opts = self.optfails.keys() + self.targets = self.targetfails.keys() + + def inc_dictionary(self, dictionary, key): + if key not in dictionary: + dictionary[key] = 0 + dictionary[key] += 1 + + def __repr__(self): + string = "Regression of LLVM revision %s in comparison to %s\n" % (self.revision_new, self.revision_old) + string += repr(self.tests) + '\n' + string += str(self.testfails) + '\n' + string += str(self.archfailes) + '\n' + string += str(self.optfails) + '\n' + string += str(self.targetfails) + '\n' + + return string + + +class TestTable(object): + """ + the table which stores a tuple of Test() objects (one per revision) and has some + convenience methods for dealing with them + """ + def __init__(self): + """ This dictionary contains {rev: [test1, test2, ...], ...}, where 'rev' is a string (revision name) and 'test#' + is a Test() object instance """ + self.table = {} + + def add_result(self, revision_name, test_name, arch, opt, target, runfailed, compfailed): + revision_name = str(revision_name) + if revision_name not in self.table: + self.table[revision_name] = [] + + test_case = TestCase(arch, opt, target) + test_case.result = TestResult(runfailed, compfailed) + + for test in self.table[revision_name]: + if test.name == test_name: + test.add_result(test_case) + return + + test = Test(test_name) + test.add_result(test_case) + self.table[revision_name].append(test) + + + def test_intersection(self, test1, test2): + """ Return test cases common for test1 and test2. If test names are different than there is nothing in common """ + if test1.name != test2.name: + return [] + return list(set(test1.test_cases) & set(test2.test_cases)) + + def test_regression(self, test1, test2): + """ Return the tuple of empty (i.e. with undefined results) TestCase() objects + corresponding to regression in test2 comparing to test1 """ + if test1.name != test2.name: + return [] + + regressed = [] + for tc1 in test1.test_cases: + for tc2 in test2.test_cases: + """ If test cases are equal (same arch, opt and target) but tc2 has more runfails or compfails """ + if tc1 == tc2 and tc1.result < tc2.result: + regressed.append(TestCase(tc1.arch, tc1.opt, tc1.target)) + return regressed + + def regression(self, revision_old, revision_new): + """ Return a tuple of Test() objects containing TestCase() object which show regression along given revisions """ + revision_old, revision_new = (str(revision_old), str(revision_new)) + if revision_new not in self.table: + raise RuntimeError("This revision in not in the database: " + str(revision_new) + " (" + str(self.table.keys()) + ")") + return + + if revision_old not in self.table: + raise RuntimeError("This revision in not in the database: " + str(revision_old) + " (" + str(self.table.keys()) + ")") + return + + regressed = [] + for test_old in self.table[revision_old]: + for test_new in self.table[revision_new]: + tr = self.test_regression(test_old, test_new) + if len(tr) == 0: + continue + test = Test(test_new.name) + for test_case in tr: + test.add_result(test_case) + regressed.append(test) + return RegressionInfo(revision_old, revision_new, regressed) + + def __repr__(self): + string = "" + for rev in self.table.keys(): + string += "[" + rev + "]:\n" + for test in self.table[rev]: + string += repr(test) + '\n' + return string + + + +class RevisionInfo(object): + """ + this class is intended to store some relevant information about curent LLVM revision + """ + def __init__(self, hostname, revision): + self.hostname, self.revision = hostname, revision + self.archs = [] + self.opts = [] + self.targets = [] + self.succeed = 0 + self.runfailed = 0 + self.compfailed = 0 + self.skipped = 0 + self.testall = 0 + self.regressions = {} + + def register_test(self, arch, opt, target, succeed, runfailed, compfailed, skipped): + if arch not in self.archs: + self.archs.append(arch) + if opt not in self.opts: + self.opts.append(opt) + if target not in self.targets: + self.targets.append(target) + self.runfailed += runfailed + self.compfailed += compfailed + self.skipped += skipped + self.succeed += succeed + + def add_regression(self, revision, regression_info): + """ input is intended to be from 'TestTable.regression(..)', 'regression_info' is a tuple of RegressionInfo() object + (regression.py) and 'revision' is tested (not current) LLVM revision name """ + if revision == self.revision: + raise RuntimeError("No regression can be found along the same LLVM revision!") + + if revision in self.regressions: + raise RuntimeError("This revision regression info is already in self.regressions!") + + self.regressions[revision] = regression_info + + def __repr__(self): + string = "%s: LLVM(%s)\n" % (self.hostname, self.revision) + string += "archs : %s\n" % (str(self.archs)) + string += "opts : %s\n" % (str(self.opts)) + string += "targets: %s\n" % (str(self.targets)) + string += "runfails: %d/%d\n" % (self.runfailed, self.testall) + string += "compfails: %d/%d\n" % (self.compfailed, self.testall) + string += "skipped: %d/%d\n" % (self.skipped, self.testall) + string += "succeed: %d/%d\n" % (self.succeed, self.testall) + return string + + + + +class ExecutionStateGatherer(object): + def __init__(self): + self.hostname = self.get_host_name() + self.revision = "" + self.rinf = [] + self.tt = TestTable() + + def switch_revision(self, revision): + print "Switching revision to " + revision + self.revision = revision + self.rinf.append(RevisionInfo(self.hostname, self.revision)) + + def current_rinf(self): + if len(self.rinf) == 0: + raise RuntimeError("self.rinf is empty. Apparently you've never invoked switch_revision") + return self.rinf[len(self.rinf) - 1] + + def add_to_tt(self, test_name, arch, opt, target, runfailed, compfailed): + if len(self.rinf) == 0: + raise RuntimeError("self.rinf is empty. Apparently you've never invoked switch_revision") + self.tt.add_result(self.revision, test_name, arch, opt, target, runfailed, compfailed) + + def add_to_rinf(self, arch, opt, target, succeed, runfailed, compfailed, skipped): + self.current_rinf().register_test(arch, opt, target, succeed, runfailed, compfailed, skipped) + + def add_to_rinf_testall(self, tried_to_test): + self.current_rinf().testall += tried_to_test + + def load_from_tt(self, tt): + # TODO: fill in self.rinf field! + self.tt = tt + REVISIONS = tt.table.keys() + self.revision = "" + if len(REVISIONS) != 0: + self.revision = REVISIONS[0] + print "ESG: loaded from 'TestTable()' with revisions", REVISIONS + + def dump(self, fname, obj): + import pickle + with open(fname, 'w') as fp: + pickle.dump(obj, fp) + + def undump(self, fname): + import pickle + with open(fname, 'r') as fp: + obj = pickle.load(fp) + return obj + + def get_host_name(self): + import socket + return socket.gethostname() + + def __repr__(self): + string = "Hostname: %s\n" % (self.hostname) + string += "Current LLVM Revision = %s\n\n" % (self.revision) + for rev_info in self.rinf: + string += repr(rev_info) + '\n' + return string + + diff --git a/regression_read.py b/regression_read.py new file mode 100755 index 00000000..10e69046 --- /dev/null +++ b/regression_read.py @@ -0,0 +1,70 @@ +#!/usr/bin/python +# +# Copyright (c) 2014, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# // Authors: Anton Mitrokhin + +from optparse import OptionParser +from regression import * +import pickle + + + +def read_test_table(filename): + with open(filename, 'r') as fp: + tt = pickle.load(fp) + return tt + + +if __name__ == '__main__': + # parsing options + class MyParser(OptionParser): + def format_epilog(self, formatter): + return self.epilog + + examples = ("Examples:\n" + + "Load test_table object\n\tregression_read.py -l\n") + + parser = MyParser(usage="Usage: regression_read.py -l [options]", epilog=examples) + parser.add_option('-l', '--load-tt', dest='load_tt', + help='load test_table.dump from file', default=None) + + (options, args) = parser.parse_args() + + tt = read_test_table(options.load_tt) + print tt + print "\n\n ------------------------\n\n" + print "Avaluable LLVM revisions:", tt.table.keys() + #print tt.regression(tt.table.keys()[1], tt.table.keys()[0]) + + + diff --git a/run_tests.py b/run_tests.py index c9d8f2ff..be8f78b6 100755 --- a/run_tests.py +++ b/run_tests.py @@ -322,12 +322,13 @@ def run_tasks_from_queue(queue, queue_ret, queue_skip, total_tests_arg, max_test olddir = "" compile_error_files = [ ] + run_succeed_files = [ ] run_error_files = [ ] skip_files = [ ] while True: filename = queue.get() if (filename == 'STOP'): - queue_ret.put((compile_error_files, run_error_files, skip_files)) + queue_ret.put((compile_error_files, run_error_files, skip_files, run_succeed_files)) if is_windows: try: os.remove("test_static.obj") @@ -350,6 +351,8 @@ def run_tasks_from_queue(queue, queue_ret, queue_skip, total_tests_arg, max_test print_debug("ERROR: run_test function raised an exception: %s\n" % (sys.exc_info()[1]), s, run_tests_log) sys.exit(-1) # This is in case the child has unexpectedly died or some other exception happened + if compile_error == 0 and run_error == 0: + run_succeed_files += [ filename ] if compile_error != 0: compile_error_files += [ filename ] if run_error != 0: @@ -503,7 +506,7 @@ def run_tests(options1, args, print_version): global s s = options.silent - # prepare run_tests_log and fail_db files + # prepare run_tests_log and fail_db file global run_tests_log if options.in_file: run_tests_log = os.getcwd() + os.sep + options.in_file @@ -590,6 +593,7 @@ def run_tests(options1, args, print_version): else: options.compiler_exe = "clang++" + # checks the required compiler otherwise prints an error message PATH_dir = string.split(os.getenv("PATH"), os.pathsep) compiler_exists = False @@ -669,6 +673,7 @@ def run_tests(options1, args, print_version): total_tests = len(files) compile_error_files = [ ] + run_succeed_files = [ ] run_error_files = [ ] skip_files = [ ] @@ -709,20 +714,42 @@ def run_tests(options1, args, print_version): if options.non_interactive == False: print_debug("\n", s, run_tests_log) - - for jb in task_threads: - if not jb.exitcode == 0: - raise OSError(2, 'Some test subprocess has thrown an exception', '') - - temp_time = (time.time() - start_time) elapsed_time = time.strftime('%Hh%Mm%Ssec.', time.gmtime(temp_time)) while not qret.empty(): - (c, r, skip) = qret.get() + (c, r, skip, ss) = qret.get() compile_error_files += c run_error_files += r skip_files += skip + run_succeed_files += ss + + # Detect opt_set + if options.no_opt == True: + opt = "-O0" + else: + opt = "-O2" + + common.ex_state.add_to_rinf_testall(total_tests) + for fname in skip_files: + # We do not add skipped tests to test table as we do not know the test result + common.ex_state.add_to_rinf(options.arch, opt, options.target, 0, 0, 0, 1) + + for fname in compile_error_files: + common.ex_state.add_to_tt(fname, options.arch, opt, options.target, 0, 1) + common.ex_state.add_to_rinf(options.arch, opt, options.target, 0, 0, 1, 0) + + for fname in run_error_files: + common.ex_state.add_to_tt(fname, options.arch, opt, options.target, 1, 0) + common.ex_state.add_to_rinf(options.arch, opt, options.target, 0, 1, 0, 0) + + for fname in run_succeed_files: + common.ex_state.add_to_tt(fname, options.arch, opt, options.target, 0, 0) + common.ex_state.add_to_rinf(options.arch, opt, options.target, 1, 0, 0, 0) + + for jb in task_threads: + if not jb.exitcode == 0: + raise OSError(2, 'Some test subprocess has thrown an exception', '') if options.non_interactive: print_debug(" Done %d / %d\n" % (finished_tests_counter.value, total_tests), s, run_tests_log) From 00d435f726cb7db62ac2901c54466ef1c05adee3 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Sun, 20 Jul 2014 15:19:06 +0400 Subject: [PATCH 18/50] fixed typos, added command line arguments check to regresion_read.py --- alloy.py | 11 ++++++++--- regression_read.py | 9 ++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/alloy.py b/alloy.py index 331ec34f..5bb189b9 100755 --- a/alloy.py +++ b/alloy.py @@ -330,9 +330,13 @@ def build_ispc(version_LLVM, make): if options.debug == True: folder += "dbg" - p = subprocess.Popen("svnversion " + folder, shell=True, \ + p = subprocess.Popen("svn info " + folder, shell=True, \ stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (revision_llvm, err) = p.communicate() + (info_llvm, err) = p.communicate() + info_llvm = re.split('\n', info_llvm) + for i in info_llvm: + if len(i) > 0 and i.startswith("Last Changed Rev: "): + common.ex_state.switch_revision(str(i[len("Last Changed Rev: "):])) try_do_LLVM("recognize LLVM revision", "svn info " + folder, True) try_do_LLVM("build ISPC with LLVM version " + version_LLVM + " ", make_ispc, True) @@ -641,7 +645,7 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, attach_mail_file(msg, performance.in_file, "performance.log") attach_mail_file(msg, "." + os.sep + "logs" + os.sep + "perf_build.log", "perf_build.log") # dumping gathered info to the file - commom.ex_state.dump(alloy_folder + "test_table.dump", commom.ex_state.tt) + common.ex_state.dump(alloy_folder + "test_table.dump", common.ex_state.tt) # sending e-mail with results if options.notify != "": fp = open(os.environ["ISPC_HOME"] + os.sep + "notify_log.log", 'rb') @@ -762,6 +766,7 @@ import datetime import copy import multiprocessing import subprocess +import re from email.MIMEMultipart import MIMEMultipart from email.MIMEBase import MIMEBase from email.mime.text import MIMEText diff --git a/regression_read.py b/regression_read.py index 10e69046..9d681172 100755 --- a/regression_read.py +++ b/regression_read.py @@ -52,14 +52,17 @@ if __name__ == '__main__': return self.epilog examples = ("Examples:\n" + - "Load test_table object\n\tregression_read.py -l\n") + "Load test_table object\n\tregression_read.py -l 'test_table.dump'\n") parser = MyParser(usage="Usage: regression_read.py -l [options]", epilog=examples) parser.add_option('-l', '--load-tt', dest='load_tt', - help='load test_table.dump from file', default=None) + help='load TestTable() from file', default=None) (options, args) = parser.parse_args() - + if (options.load_tt == None): + parser.print_help() + exit(0) + tt = read_test_table(options.load_tt) print tt print "\n\n ------------------------\n\n" From ece37ea4f51a4491d564da63aa8f1bc6ef099c2b Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Mon, 21 Jul 2014 16:11:27 +0400 Subject: [PATCH 19/50] regression_read.py improved --- regression.py | 2 +- regression_read.py | 82 +++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 74 insertions(+), 10 deletions(-) diff --git a/regression.py b/regression.py index 6ce0c532..5718e881 100644 --- a/regression.py +++ b/regression.py @@ -77,7 +77,7 @@ class TestCase(object): def __repr__(self): string = "%s %s %s: " % (self.arch, self.opt, self.target) - string = string + repr(self.result) + '\n' + string = string + repr(self.result) return string def __hash__(self): diff --git a/regression_read.py b/regression_read.py index 9d681172..42c92363 100755 --- a/regression_read.py +++ b/regression_read.py @@ -35,7 +35,7 @@ from optparse import OptionParser from regression import * -import pickle +import pickle, re @@ -44,7 +44,22 @@ def read_test_table(filename): tt = pickle.load(fp) return tt - + +def print_with_specific_results(tests, runfailed, compfailed): + for test in tests: + for test_case in test.test_cases: + if test_case.result == TestResult(runfailed, compfailed): + print test.name.rjust(40) + repr(test_case).rjust(50) + + + +def check_rev_in_tt(tt, rev, tt_location): + if not rev in tt.table.keys(): + print "Unable to locate", rev, "in table", tt_location + print "Available LLVM revisions:", tt.table.keys() + exit(0) + + if __name__ == '__main__': # parsing options class MyParser(OptionParser): @@ -52,22 +67,71 @@ if __name__ == '__main__': return self.epilog examples = ("Examples:\n" + - "Load test_table object\n\tregression_read.py -l 'test_table.dump'\n") - + "Load test_table object\n\tregression_read.py -l 'test_table.dump'\n" + + "Show runfailed, compfailed and succeed tests in rev '213493'\n\t" + + "regression_read.py -l 'test_table.dump' -r '213493' --succeed --runfailed --compfailed\n" + + "Show regression between two revisions\n\t" + + "regression_read.py -l 'test_table.dump' -R '210929 213493'\n") + parser = MyParser(usage="Usage: regression_read.py -l [options]", epilog=examples) parser.add_option('-l', '--load-tt', dest='load_tt', help='load TestTable() from file', default=None) + parser.add_option('-r', '--revision', dest='revision', + help='show only specified revision', default=None) + parser.add_option('--runfailed', dest='runfailed', + help='show runfailed tests', default=False, action='store_true') + parser.add_option('--compfailed', dest='compfailed', + help='show compfailed tests', default=False, action='store_true') + parser.add_option('--succeed', dest='succeed', + help='show succeed tests', default=False, action='store_true') + parser.add_option('-R', '--regression', dest='regression', + help='show regression between two specified revisions', default="") (options, args) = parser.parse_args() if (options.load_tt == None): parser.print_help() exit(0) - + tt = read_test_table(options.load_tt) - print tt - print "\n\n ------------------------\n\n" - print "Avaluable LLVM revisions:", tt.table.keys() - #print tt.regression(tt.table.keys()[1], tt.table.keys()[0]) + print "Available LLVM revisions:", tt.table.keys() + + if options.revision != None: + check_rev_in_tt(tt, options.revision, options.load_tt) + revisions = [options.revision] + else: + revisions = tt.table.keys() + # print test cases + if (options.succeed): + print "\n\n Succeed:" + for rev in revisions: + print "Revision %s" % (rev) + print_with_specific_results(tt.table[rev], 0, 0) + + if (options.runfailed): + print "\n\n Runfailed:" + for rev in revisions: + print "Revision %s" % (rev) + print_with_specific_results(tt.table[rev], 1, 0) + + if (options.compfailed): + print "\n\n Compfailed:" + for rev in revisions: + print "Revision %s" % (rev) + print_with_specific_results(tt.table[rev], 0, 1) + + + # print regression + if options.regression != "": + regr_revs = re.split('\ ', options.regression) + if len(regr_revs) != 2: + print "Invalid input:", regr_revs + exit(0) + + check_rev_in_tt(tt, regr_revs[0], options.load_tt) + check_rev_in_tt(tt, regr_revs[1], options.load_tt) + + print tt.regression(regr_revs[0], regr_revs[1]) + From ad3b66a1781ff20494f07cb5433f5842c4e727d2 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Mon, 21 Jul 2014 16:12:44 +0400 Subject: [PATCH 20/50] renamed regression_read.py -> tt_read.py --- regression_read.py => tt_read.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename regression_read.py => tt_read.py (100%) diff --git a/regression_read.py b/tt_read.py similarity index 100% rename from regression_read.py rename to tt_read.py From fb82d37f09798690e359fc2ebf74a184b1f12ef2 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Mon, 21 Jul 2014 16:18:40 +0400 Subject: [PATCH 21/50] add host name printing in stability.log and e-mail body --- alloy.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/alloy.py b/alloy.py index 5bb189b9..cfd1dc38 100755 --- a/alloy.py +++ b/alloy.py @@ -515,6 +515,7 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, # begin validation run for stabitily common.remove_if_exists(stability.in_file) R = [[[],[]],[[],[]],[[],[]],[[],[]]] + print_debug("\n" + common.get_host_name() + "\n", False, stability_log) print_debug("\n_________________________STABILITY REPORT_________________________\n", False, stability_log) for i in range(0,len(LLVM)): print_version = 2 @@ -652,6 +653,8 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, f_lines = fp.readlines() fp.close() body = "" + body += "Hostname: " + common.get_host_name() + "\n\n" + if not sys.exc_info()[0] == None: body = body + "Last exception: " + str(sys.exc_info()) + '\n' for i in range(0,len(f_lines)): From 48e4373d28de78f47ef1529fa9bb210933e1be49 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Mon, 21 Jul 2014 19:36:35 +0400 Subject: [PATCH 22/50] comments on merge request are taken into account --- alloy.py | 4 +- common.py | 352 ++++++++++++++++++++++++++++++- regression.py | 376 ---------------------------------- tt_read.py => tt_dump_read.py | 0 4 files changed, 349 insertions(+), 383 deletions(-) delete mode 100644 regression.py rename tt_read.py => tt_dump_read.py (100%) diff --git a/alloy.py b/alloy.py index cfd1dc38..6fcfca96 100755 --- a/alloy.py +++ b/alloy.py @@ -722,9 +722,9 @@ def Main(): global alloy_folder alloy_folder = os.getcwd() + os.sep + f_date + os.sep global alloy_build - alloy_build = os.getcwd() + os.sep + f_date + os.sep + "alloy_build.log" + alloy_build = alloy_folder + "alloy_build.log" global stability_log - stability_log = os.getcwd() + os.sep + f_date + os.sep + "stability.log" + stability_log = alloy_folder + "stability.log" current_path = os.getcwd() make = "make -j" + options.speed if os.environ["ISPC_HOME"] != os.getcwd(): diff --git a/common.py b/common.py index 0fda9b45..e342d8cf 100755 --- a/common.py +++ b/common.py @@ -31,17 +31,13 @@ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# // Author: Filippov Ilia +# // Author: Filippov Ilia, Anton Mitrokhin, Vsevolod Livinskiy import sys import os import errno import shutil -from regression import * -# this class instance is intended to gather and store all information -# regarding the testing process. Defined in 'regression.py' -ex_state = ExecutionStateGatherer() # load/save almost every object to a file (good for bug reproducing) def dump(fname, obj): @@ -157,3 +153,349 @@ def check_tools(m): if int(t11[j])>input_tools[t][0][j]: break return ret + + + + + +# regression testing functionality +class TestResult(object): + """ + this class stores basicly two integers which stand for the result + of the test: (runfail{0/1}, compfail{0/1}). other values are + deemed invalid. the __cmp__ function of this class is used to + define what test regression actually is. + """ + def __init__(self, runfailed, compfailed): + self.runfailed, self.compfailed = (runfailed, compfailed) + + def __cmp__(self, other): + if isinstance(other, TestResult): + if self.runfailed == other.runfailed and \ + self.compfailed == other.compfailed: + return 0 + elif self.compfailed > other.compfailed: + return 1 + elif self.runfailed > other.runfailed and \ + self.compfailed == other.compfailed: + return 1 + else: + return -1 + + raise RuntimeError("Wrong type for comparioson") + return NotImplemented + + def __repr__(self): + if (self.runfailed < 0 or self.compfailed < 0): + return "(Undefined)" + return "(r%d c%d)" % (self.runfailed, self.compfailed) + + +class TestCase(object): + """ + the TestCase() is a combination of parameters the tast was run with: + the architecture (x86, x86-64 ...), compiler optimization (-O0, -O2 ...) + and target (sse, avx ...). we also store the result of the test here. + """ + def __init__(self, arch, opt, target): + self.arch, self.opt, self.target = (arch, opt, target) + self.result = TestResult(-1, -1) + + def __repr__(self): + string = "%s %s %s: " % (self.arch, self.opt, self.target) + string = string + repr(self.result) + return string + + def __hash__(self): + return hash(self.arch + self.opt + self.target) + + def __ne__(self, other): + if isinstance(other, TestCase): + if hash(self.arch + self.opt + self.target) != hash(other): + return True + return False + raise RuntimeError("Wrong type for comparioson") + return NotImplemented + + def __eq__(self, other): + if isinstance(other, TestCase): + return not self.__ne__(other) + raise RuntimeError("Wrong type for comparioson") + return NotImplemented + + +class Test(object): + """ + Test() stores all TestCase() objects for a given test file name + i.e. all archs/opts/targets/ and corresponding testing results. + """ + def __init__(self, name): + self.name = name + self.test_cases = [] + + def add_result(self, test_case): + if test_case in self.test_cases: + raise RuntimeError("This test case is already in the list: " + repr(test_case)) + return + self.test_cases.append(test_case) + + def __repr__(self): + string = self.name + '\n' + string = string.rjust(20) + for test_case in self.test_cases: + string += repr(test_case).rjust(60) + '\n' + return string + + def __hash__(self): + return hash(self.name) + + def __ne__(self, other): + if isinstance(other, Test): + if hash(self) != hash(other): + return True + return False + return NotImplemented + + def __eq__(self, other): + if isinstance(other, Test): + return not self.__ne__(other) + return NotImplemented + + +class RegressionInfo(object): + """ + service class which provides some statistics on a given regression. + the regression test names and cases are given in a form of Test() objects + with empty (-1, -1) results + """ + def __init__(self, revision_old, revision_new, tests): + self.revision_old, self.revision_new = (revision_old, revision_new) + self.tests = tests + self.archfailes = {} + self.optfails = {} + self.targetfails = {} + self.testfails = {} + self.archs = [] + self.opts = [] + self.targets = [] + + for test in tests: + for test_case in test.test_cases: + self.inc_dictionary(self.testfails, test.name) + self.inc_dictionary(self.archfailes, test_case.arch) + self.inc_dictionary(self.optfails, test_case.opt) + self.inc_dictionary(self.targetfails, test_case.target) + + self.archs = self.archfailes.keys() + self.opts = self.optfails.keys() + self.targets = self.targetfails.keys() + + def inc_dictionary(self, dictionary, key): + if key not in dictionary: + dictionary[key] = 0 + dictionary[key] += 1 + + def __repr__(self): + string = "Regression of LLVM revision %s in comparison to %s\n" % (self.revision_new, self.revision_old) + string += repr(self.tests) + '\n' + string += str(self.testfails) + '\n' + string += str(self.archfailes) + '\n' + string += str(self.optfails) + '\n' + string += str(self.targetfails) + '\n' + + return string + + +class TestTable(object): + """ + the table which stores a tuple of Test() objects (one per revision) and has some + convenience methods for dealing with them + """ + def __init__(self): + """ This dictionary contains {rev: [test1, test2, ...], ...}, where 'rev' is a string (revision name) and 'test#' + is a Test() object instance """ + self.table = {} + + def add_result(self, revision_name, test_name, arch, opt, target, runfailed, compfailed): + revision_name = str(revision_name) + if revision_name not in self.table: + self.table[revision_name] = [] + + test_case = TestCase(arch, opt, target) + test_case.result = TestResult(runfailed, compfailed) + + for test in self.table[revision_name]: + if test.name == test_name: + test.add_result(test_case) + return + + test = Test(test_name) + test.add_result(test_case) + self.table[revision_name].append(test) + + def test_intersection(self, test1, test2): + """ Return test cases common for test1 and test2. If test names are different than there is nothing in common """ + if test1.name != test2.name: + return [] + return list(set(test1.test_cases) & set(test2.test_cases)) + + def test_regression(self, test1, test2): + """ Return the tuple of empty (i.e. with undefined results) TestCase() objects + corresponding to regression in test2 comparing to test1 """ + if test1.name != test2.name: + return [] + + regressed = [] + for tc1 in test1.test_cases: + for tc2 in test2.test_cases: + """ If test cases are equal (same arch, opt and target) but tc2 has more runfails or compfails """ + if tc1 == tc2 and tc1.result < tc2.result: + regressed.append(TestCase(tc1.arch, tc1.opt, tc1.target)) + return regressed + + def regression(self, revision_old, revision_new): + """ Return a tuple of Test() objects containing TestCase() object which show regression along given revisions """ + revision_old, revision_new = (str(revision_old), str(revision_new)) + if revision_new not in self.table: + raise RuntimeError("This revision in not in the database: " + str(revision_new) + " (" + str(self.table.keys()) + ")") + return + + if revision_old not in self.table: + raise RuntimeError("This revision in not in the database: " + str(revision_old) + " (" + str(self.table.keys()) + ")") + return + + regressed = [] + for test_old in self.table[revision_old]: + for test_new in self.table[revision_new]: + tr = self.test_regression(test_old, test_new) + if len(tr) == 0: + continue + test = Test(test_new.name) + for test_case in tr: + test.add_result(test_case) + regressed.append(test) + return RegressionInfo(revision_old, revision_new, regressed) + + def __repr__(self): + string = "" + for rev in self.table.keys(): + string += "[" + rev + "]:\n" + for test in self.table[rev]: + string += repr(test) + '\n' + return string + + +class RevisionInfo(object): + """ + this class is intended to store some relevant information about curent LLVM revision + """ + def __init__(self, hostname, revision): + self.hostname, self.revision = hostname, revision + self.archs = [] + self.opts = [] + self.targets = [] + self.succeed = 0 + self.runfailed = 0 + self.compfailed = 0 + self.skipped = 0 + self.testall = 0 + self.regressions = {} + + def register_test(self, arch, opt, target, succeed, runfailed, compfailed, skipped): + if arch not in self.archs: + self.archs.append(arch) + if opt not in self.opts: + self.opts.append(opt) + if target not in self.targets: + self.targets.append(target) + self.runfailed += runfailed + self.compfailed += compfailed + self.skipped += skipped + self.succeed += succeed + + def add_regression(self, revision, regression_info): + """ input is intended to be from 'TestTable.regression(..)', 'regression_info' is a tuple of RegressionInfo() object + (regression.py) and 'revision' is tested (not current) LLVM revision name """ + if revision == self.revision: + raise RuntimeError("No regression can be found along the same LLVM revision!") + + if revision in self.regressions: + raise RuntimeError("This revision regression info is already in self.regressions!") + + self.regressions[revision] = regression_info + + def __repr__(self): + string = "%s: LLVM(%s)\n" % (self.hostname, self.revision) + string += "archs : %s\n" % (str(self.archs)) + string += "opts : %s\n" % (str(self.opts)) + string += "targets: %s\n" % (str(self.targets)) + string += "runfails: %d/%d\n" % (self.runfailed, self.testall) + string += "compfails: %d/%d\n" % (self.compfailed, self.testall) + string += "skipped: %d/%d\n" % (self.skipped, self.testall) + string += "succeed: %d/%d\n" % (self.succeed, self.testall) + return string + + +class ExecutionStateGatherer(object): + def __init__(self): + self.hostname = self.get_host_name() + self.revision = "" + self.rinf = [] + self.tt = TestTable() + + def switch_revision(self, revision): + print "Switching revision to " + revision + self.revision = revision + self.rinf.append(RevisionInfo(self.hostname, self.revision)) + + def current_rinf(self): + if len(self.rinf) == 0: + raise RuntimeError("self.rinf is empty. Apparently you've never invoked switch_revision") + return self.rinf[len(self.rinf) - 1] + + def add_to_tt(self, test_name, arch, opt, target, runfailed, compfailed): + if len(self.rinf) == 0: + raise RuntimeError("self.rinf is empty. Apparently you've never invoked switch_revision") + self.tt.add_result(self.revision, test_name, arch, opt, target, runfailed, compfailed) + + def add_to_rinf(self, arch, opt, target, succeed, runfailed, compfailed, skipped): + self.current_rinf().register_test(arch, opt, target, succeed, runfailed, compfailed, skipped) + + def add_to_rinf_testall(self, tried_to_test): + self.current_rinf().testall += tried_to_test + + def load_from_tt(self, tt): + # TODO: fill in self.rinf field! + self.tt = tt + REVISIONS = tt.table.keys() + self.revision = "" + if len(REVISIONS) != 0: + self.revision = REVISIONS[0] + print "ESG: loaded from 'TestTable()' with revisions", REVISIONS + + def dump(self, fname, obj): + import pickle + with open(fname, 'w') as fp: + pickle.dump(obj, fp) + + def undump(self, fname): + import pickle + with open(fname, 'r') as fp: + obj = pickle.load(fp) + return obj + + def get_host_name(self): + import socket + return socket.gethostname() + + def __repr__(self): + string = "Hostname: %s\n" % (self.hostname) + string += "Current LLVM Revision = %s\n\n" % (self.revision) + for rev_info in self.rinf: + string += repr(rev_info) + '\n' + return string + + +# this class instance is intended to gather and store all information +# regarding the testing process. +ex_state = ExecutionStateGatherer() diff --git a/regression.py b/regression.py deleted file mode 100644 index 5718e881..00000000 --- a/regression.py +++ /dev/null @@ -1,376 +0,0 @@ -#!/usr/bin/python -# -# Copyright (c) 2014, Intel Corporation -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Intel Corporation nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -# // Authors: Anton Mitrokhin, Vsevolod Livinskiy - -class TestResult(object): - """ - this class stores basicly two integers which stand for the result - of the test: (runfail{0/1}, compfail{0/1}). other values are - deemed invalid. the __cmp__ function of this class is used to - define what test regression actually is. - """ - def __init__(self, runfailed, compfailed): - self.runfailed, self.compfailed = (runfailed, compfailed) - - def __cmp__(self, other): - if isinstance(other, TestResult): - if self.runfailed == other.runfailed and \ - self.compfailed == other.compfailed: - return 0 - elif self.compfailed > other.compfailed: - return 1 - elif self.runfailed > other.runfailed and \ - self.compfailed == other.compfailed: - return 1 - else: - return -1 - - raise RuntimeError("Wrong type for comparioson") - return NotImplemented - - def __repr__(self): - if (self.runfailed < 0 or self.compfailed < 0): - return "(Undefined)" - return "(r%d c%d)" % (self.runfailed, self.compfailed) - - -class TestCase(object): - """ - the TestCase() is a combination of parameters the tast was run with: - the architecture (x86, x86-64 ...), compiler optimization (-O0, -O2 ...) - and target (sse, avx ...). we also store the result of the test here. - """ - def __init__(self, arch, opt, target): - self.arch, self.opt, self.target = (arch, opt, target) - self.result = TestResult(-1, -1) - - def __repr__(self): - string = "%s %s %s: " % (self.arch, self.opt, self.target) - string = string + repr(self.result) - return string - - def __hash__(self): - return hash(self.arch + self.opt + self.target) - - def __ne__(self, other): - if isinstance(other, TestCase): - if hash(self.arch + self.opt + self.target) != hash(other): - return True - return False - raise RuntimeError("Wrong type for comparioson") - return NotImplemented - - def __eq__(self, other): - if isinstance(other, TestCase): - return not self.__ne__(other) - raise RuntimeError("Wrong type for comparioson") - return NotImplemented - - -class Test(object): - """ - Test() stores all TestCase() objects for a given test file name - i.e. all archs/opts/targets/ and corresponding testing results. - """ - def __init__(self, name): - self.name = name - self.test_cases = [] - - def add_result(self, test_case): - if test_case in self.test_cases: - raise RuntimeError("This test case is already in the list: " + repr(test_case)) - return - self.test_cases.append(test_case) - - def __repr__(self): - string = self.name + '\n' - string = string.rjust(20) - for test_case in self.test_cases: - string += repr(test_case).rjust(60) + '\n' - return string - - def __hash__(self): - return hash(self.name) - - def __ne__(self, other): - if isinstance(other, Test): - if hash(self) != hash(other): - return True - return False - return NotImplemented - - def __eq__(self, other): - if isinstance(other, Test): - return not self.__ne__(other) - return NotImplemented - - -class RegressionInfo(object): - """ - service class which provides some statistics on a given regression. - the regression test names and cases are given in a form of Test() objects - with empty (-1, -1) results - """ - def __init__(self, revision_old, revision_new, tests): - self.revision_old, self.revision_new = (revision_old, revision_new) - self.tests = tests - self.archfailes = {} - self.optfails = {} - self.targetfails = {} - self.testfails = {} - self.archs = [] - self.opts = [] - self.targets = [] - - for test in tests: - for test_case in test.test_cases: - self.inc_dictionary(self.testfails, test.name) - self.inc_dictionary(self.archfailes, test_case.arch) - self.inc_dictionary(self.optfails, test_case.opt) - self.inc_dictionary(self.targetfails, test_case.target) - - self.archs = self.archfailes.keys() - self.opts = self.optfails.keys() - self.targets = self.targetfails.keys() - - def inc_dictionary(self, dictionary, key): - if key not in dictionary: - dictionary[key] = 0 - dictionary[key] += 1 - - def __repr__(self): - string = "Regression of LLVM revision %s in comparison to %s\n" % (self.revision_new, self.revision_old) - string += repr(self.tests) + '\n' - string += str(self.testfails) + '\n' - string += str(self.archfailes) + '\n' - string += str(self.optfails) + '\n' - string += str(self.targetfails) + '\n' - - return string - - -class TestTable(object): - """ - the table which stores a tuple of Test() objects (one per revision) and has some - convenience methods for dealing with them - """ - def __init__(self): - """ This dictionary contains {rev: [test1, test2, ...], ...}, where 'rev' is a string (revision name) and 'test#' - is a Test() object instance """ - self.table = {} - - def add_result(self, revision_name, test_name, arch, opt, target, runfailed, compfailed): - revision_name = str(revision_name) - if revision_name not in self.table: - self.table[revision_name] = [] - - test_case = TestCase(arch, opt, target) - test_case.result = TestResult(runfailed, compfailed) - - for test in self.table[revision_name]: - if test.name == test_name: - test.add_result(test_case) - return - - test = Test(test_name) - test.add_result(test_case) - self.table[revision_name].append(test) - - - def test_intersection(self, test1, test2): - """ Return test cases common for test1 and test2. If test names are different than there is nothing in common """ - if test1.name != test2.name: - return [] - return list(set(test1.test_cases) & set(test2.test_cases)) - - def test_regression(self, test1, test2): - """ Return the tuple of empty (i.e. with undefined results) TestCase() objects - corresponding to regression in test2 comparing to test1 """ - if test1.name != test2.name: - return [] - - regressed = [] - for tc1 in test1.test_cases: - for tc2 in test2.test_cases: - """ If test cases are equal (same arch, opt and target) but tc2 has more runfails or compfails """ - if tc1 == tc2 and tc1.result < tc2.result: - regressed.append(TestCase(tc1.arch, tc1.opt, tc1.target)) - return regressed - - def regression(self, revision_old, revision_new): - """ Return a tuple of Test() objects containing TestCase() object which show regression along given revisions """ - revision_old, revision_new = (str(revision_old), str(revision_new)) - if revision_new not in self.table: - raise RuntimeError("This revision in not in the database: " + str(revision_new) + " (" + str(self.table.keys()) + ")") - return - - if revision_old not in self.table: - raise RuntimeError("This revision in not in the database: " + str(revision_old) + " (" + str(self.table.keys()) + ")") - return - - regressed = [] - for test_old in self.table[revision_old]: - for test_new in self.table[revision_new]: - tr = self.test_regression(test_old, test_new) - if len(tr) == 0: - continue - test = Test(test_new.name) - for test_case in tr: - test.add_result(test_case) - regressed.append(test) - return RegressionInfo(revision_old, revision_new, regressed) - - def __repr__(self): - string = "" - for rev in self.table.keys(): - string += "[" + rev + "]:\n" - for test in self.table[rev]: - string += repr(test) + '\n' - return string - - - -class RevisionInfo(object): - """ - this class is intended to store some relevant information about curent LLVM revision - """ - def __init__(self, hostname, revision): - self.hostname, self.revision = hostname, revision - self.archs = [] - self.opts = [] - self.targets = [] - self.succeed = 0 - self.runfailed = 0 - self.compfailed = 0 - self.skipped = 0 - self.testall = 0 - self.regressions = {} - - def register_test(self, arch, opt, target, succeed, runfailed, compfailed, skipped): - if arch not in self.archs: - self.archs.append(arch) - if opt not in self.opts: - self.opts.append(opt) - if target not in self.targets: - self.targets.append(target) - self.runfailed += runfailed - self.compfailed += compfailed - self.skipped += skipped - self.succeed += succeed - - def add_regression(self, revision, regression_info): - """ input is intended to be from 'TestTable.regression(..)', 'regression_info' is a tuple of RegressionInfo() object - (regression.py) and 'revision' is tested (not current) LLVM revision name """ - if revision == self.revision: - raise RuntimeError("No regression can be found along the same LLVM revision!") - - if revision in self.regressions: - raise RuntimeError("This revision regression info is already in self.regressions!") - - self.regressions[revision] = regression_info - - def __repr__(self): - string = "%s: LLVM(%s)\n" % (self.hostname, self.revision) - string += "archs : %s\n" % (str(self.archs)) - string += "opts : %s\n" % (str(self.opts)) - string += "targets: %s\n" % (str(self.targets)) - string += "runfails: %d/%d\n" % (self.runfailed, self.testall) - string += "compfails: %d/%d\n" % (self.compfailed, self.testall) - string += "skipped: %d/%d\n" % (self.skipped, self.testall) - string += "succeed: %d/%d\n" % (self.succeed, self.testall) - return string - - - - -class ExecutionStateGatherer(object): - def __init__(self): - self.hostname = self.get_host_name() - self.revision = "" - self.rinf = [] - self.tt = TestTable() - - def switch_revision(self, revision): - print "Switching revision to " + revision - self.revision = revision - self.rinf.append(RevisionInfo(self.hostname, self.revision)) - - def current_rinf(self): - if len(self.rinf) == 0: - raise RuntimeError("self.rinf is empty. Apparently you've never invoked switch_revision") - return self.rinf[len(self.rinf) - 1] - - def add_to_tt(self, test_name, arch, opt, target, runfailed, compfailed): - if len(self.rinf) == 0: - raise RuntimeError("self.rinf is empty. Apparently you've never invoked switch_revision") - self.tt.add_result(self.revision, test_name, arch, opt, target, runfailed, compfailed) - - def add_to_rinf(self, arch, opt, target, succeed, runfailed, compfailed, skipped): - self.current_rinf().register_test(arch, opt, target, succeed, runfailed, compfailed, skipped) - - def add_to_rinf_testall(self, tried_to_test): - self.current_rinf().testall += tried_to_test - - def load_from_tt(self, tt): - # TODO: fill in self.rinf field! - self.tt = tt - REVISIONS = tt.table.keys() - self.revision = "" - if len(REVISIONS) != 0: - self.revision = REVISIONS[0] - print "ESG: loaded from 'TestTable()' with revisions", REVISIONS - - def dump(self, fname, obj): - import pickle - with open(fname, 'w') as fp: - pickle.dump(obj, fp) - - def undump(self, fname): - import pickle - with open(fname, 'r') as fp: - obj = pickle.load(fp) - return obj - - def get_host_name(self): - import socket - return socket.gethostname() - - def __repr__(self): - string = "Hostname: %s\n" % (self.hostname) - string += "Current LLVM Revision = %s\n\n" % (self.revision) - for rev_info in self.rinf: - string += repr(rev_info) + '\n' - return string - - diff --git a/tt_read.py b/tt_dump_read.py similarity index 100% rename from tt_read.py rename to tt_dump_read.py From a051c9bbd8cfbd3485733ee3bfc817d01641af48 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Mon, 21 Jul 2014 19:48:42 +0400 Subject: [PATCH 23/50] tt_dump_read.py import bux fixed --- tt_dump_read.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tt_dump_read.py b/tt_dump_read.py index 42c92363..0263ec32 100755 --- a/tt_dump_read.py +++ b/tt_dump_read.py @@ -34,7 +34,7 @@ # // Authors: Anton Mitrokhin from optparse import OptionParser -from regression import * +from common import * import pickle, re From b6592c796dbe293d44132d8fa3291ee85f7cd927 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Tue, 22 Jul 2014 12:20:34 +0400 Subject: [PATCH 24/50] fixed run_tests.py bug --- common.py | 2 +- run_tests.py | 32 +++++++++++++++++++------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/common.py b/common.py index e342d8cf..55f998bf 100755 --- a/common.py +++ b/common.py @@ -442,9 +442,9 @@ class ExecutionStateGatherer(object): self.revision = "" self.rinf = [] self.tt = TestTable() + self.switch_revision("undefined") def switch_revision(self, revision): - print "Switching revision to " + revision self.revision = revision self.rinf.append(RevisionInfo(self.hostname, self.revision)) diff --git a/run_tests.py b/run_tests.py index eb39b188..8644545a 100755 --- a/run_tests.py +++ b/run_tests.py @@ -729,22 +729,28 @@ def run_tests(options1, args, print_version): else: opt = "-O2" - common.ex_state.add_to_rinf_testall(total_tests) - for fname in skip_files: - # We do not add skipped tests to test table as we do not know the test result - common.ex_state.add_to_rinf(options.arch, opt, options.target, 0, 0, 0, 1) + try: + common.ex_state.add_to_rinf_testall(total_tests) + for fname in skip_files: + # We do not add skipped tests to test table as we do not know the test result + common.ex_state.add_to_rinf(options.arch, opt, options.target, 0, 0, 0, 1) - for fname in compile_error_files: - common.ex_state.add_to_tt(fname, options.arch, opt, options.target, 0, 1) - common.ex_state.add_to_rinf(options.arch, opt, options.target, 0, 0, 1, 0) + for fname in compile_error_files: + common.ex_state.add_to_tt(fname, options.arch, opt, options.target, 0, 1) + common.ex_state.add_to_rinf(options.arch, opt, options.target, 0, 0, 1, 0) + + for fname in run_error_files: + common.ex_state.add_to_tt(fname, options.arch, opt, options.target, 1, 0) + common.ex_state.add_to_rinf(options.arch, opt, options.target, 0, 1, 0, 0) + + for fname in run_succeed_files: + common.ex_state.add_to_tt(fname, options.arch, opt, options.target, 0, 0) + common.ex_state.add_to_rinf(options.arch, opt, options.target, 1, 0, 0, 0) + + except: + print_debug("Exception in ex_state. Skipping...", s, run_tests_log) - for fname in run_error_files: - common.ex_state.add_to_tt(fname, options.arch, opt, options.target, 1, 0) - common.ex_state.add_to_rinf(options.arch, opt, options.target, 0, 1, 0, 0) - for fname in run_succeed_files: - common.ex_state.add_to_tt(fname, options.arch, opt, options.target, 0, 0) - common.ex_state.add_to_rinf(options.arch, opt, options.target, 1, 0, 0, 0) for jb in task_threads: if not jb.exitcode == 0: From 725be222acda6cb8f23c392bba04c9b9eac068b9 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Wed, 30 Jul 2014 11:50:15 +0400 Subject: [PATCH 25/50] added LLVM_3_6 var --- Makefile | 7 +++++++ builtins.cpp | 6 +++--- builtins/util.m4 | 7 ++++++- cbackend.cpp | 26 +++++++++++++------------- ctx.cpp | 4 ++-- ctx.h | 2 +- expr.cpp | 2 +- func.cpp | 6 +++--- ispc.cpp | 2 +- ispc.h | 4 ++-- main.cpp | 6 ++++-- module.cpp | 8 ++++---- module.h | 2 +- opt.cpp | 8 ++++---- type.cpp | 4 ++-- 15 files changed, 54 insertions(+), 40 deletions(-) diff --git a/Makefile b/Makefile index 29b5875e..fb93e324 100644 --- a/Makefile +++ b/Makefile @@ -117,6 +117,10 @@ ifeq ($(LLVM_VERSION),LLVM_3_5) ISPC_LIBS += -lcurses -lz endif +ifeq ($(LLVM_VERSION),LLVM_3_6) + ISPC_LIBS += -lcurses -lz +endif + ifeq ($(ARCH_OS),Linux) ISPC_LIBS += -ldl endif @@ -153,6 +157,9 @@ CXXFLAGS=$(OPT) $(LLVM_CXXFLAGS) -I. -Iobjs/ -I$(CLANG_INCLUDE) \ ifeq ($(LLVM_VERSION),LLVM_3_5) CXXFLAGS+=-std=c++11 -Wno-c99-extensions -Wno-deprecated-register endif +ifeq ($(LLVM_VERSION),LLVM_3_6) + CXXFLAGS+=-std=c++11 -Wno-c99-extensions -Wno-deprecated-register +endif ifneq ($(ARM_ENABLED), 0) CXXFLAGS+=-DISPC_ARM_ENABLED endif diff --git a/builtins.cpp b/builtins.cpp index 472c2ce8..377f4f50 100644 --- a/builtins.cpp +++ b/builtins.cpp @@ -66,7 +66,7 @@ #include #include #endif -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) #include #else #include @@ -705,7 +705,7 @@ AddBitcodeToModule(const unsigned char *bitcode, int length, llvm::Module *module, SymbolTable *symbolTable) { llvm::StringRef sb = llvm::StringRef((char *)bitcode, length); llvm::MemoryBuffer *bcBuf = llvm::MemoryBuffer::getMemBuffer(sb); -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) llvm::ErrorOr ModuleOrErr = llvm::parseBitcodeFile(bcBuf, *g->ctx); if (std::error_code EC = ModuleOrErr.getError()) Error(SourcePos(), "Error parsing stdlib bitcode: %s", EC.message().c_str()); @@ -762,7 +762,7 @@ AddBitcodeToModule(const unsigned char *bitcode, int length, // architecture and investigate what happened. // Generally we allow library DataLayout to be subset of module // DataLayout or library DataLayout to be empty. -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) if (!VerifyDataLayoutCompatibility(module->getDataLayoutStr(), bcModule->getDataLayoutStr())) { Warning(SourcePos(), "Module DataLayout is incompatible with " diff --git a/builtins/util.m4 b/builtins/util.m4 index b014645e..52c642b4 100644 --- a/builtins/util.m4 +++ b/builtins/util.m4 @@ -1500,10 +1500,12 @@ define <$1 x $2> @__atomic_compare_exchange_$3_global($2* %ptr, <$1 x $2> %cmp, ifelse(LLVM_VERSION,LLVM_3_5,` %r_LANE_ID_t = cmpxchg $2 * %ptr, $2 %cmp_LANE_ID, $2 %val_LANE_ID seq_cst seq_cst %r_LANE_ID = extractvalue { $2, i1 } %r_LANE_ID_t, 0 + ',LLVM_VERSION,LLVM_3_6,` + %r_LANE_ID_t = cmpxchg $2 * %ptr, $2 %cmp_LANE_ID, $2 %val_LANE_ID seq_cst seq_cst + %r_LANE_ID = extractvalue { $2, i1 } %r_LANE_ID_t, 0 ',` %r_LANE_ID = cmpxchg $2 * %ptr, $2 %cmp_LANE_ID, $2 %val_LANE_ID seq_cst ') - %rp_LANE_ID = getelementptr $2 * %rptr32, i32 LANE store $2 %r_LANE_ID, $2 * %rp_LANE_ID') @@ -1516,6 +1518,9 @@ define $2 @__atomic_compare_exchange_uniform_$3_global($2* %ptr, $2 %cmp, ifelse(LLVM_VERSION,LLVM_3_5,` %r_t = cmpxchg $2 * %ptr, $2 %cmp, $2 %val seq_cst seq_cst %r = extractvalue { $2, i1 } %r_t, 0 + ',LLVM_VERSION,LLVM_3_6,` + %r_t = cmpxchg $2 * %ptr, $2 %cmp, $2 %val seq_cst seq_cst + %r = extractvalue { $2, i1 } %r_t, 0 ',` %r = cmpxchg $2 * %ptr, $2 %cmp, $2 %val seq_cst ') diff --git a/cbackend.cpp b/cbackend.cpp index 3d515a60..aa7a9aca 100644 --- a/cbackend.cpp +++ b/cbackend.cpp @@ -63,7 +63,7 @@ #include "llvm/Analysis/ConstantsScanner.h" #include "llvm/Analysis/FindUsedTypes.h" #include "llvm/Analysis/LoopInfo.h" -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) #include "llvm/IR/Verifier.h" #include #include "llvm/IR/CallSite.h" @@ -250,7 +250,7 @@ namespace { class CBEMCAsmInfo : public llvm::MCAsmInfo { public: CBEMCAsmInfo() { -#if !defined(LLVM_3_5) +#if !defined(LLVM_3_5) && !defined(LLVM_3_6) GlobalPrefix = ""; #endif PrivateGlobalPrefix = ""; @@ -465,7 +465,7 @@ namespace { // Must not be used in inline asm, extractelement, or shufflevector. if (I.hasOneUse()) { -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) const llvm::Instruction &User = llvm::cast(*I.user_back()); #else const llvm::Instruction &User = llvm::cast(*I.use_back()); @@ -477,7 +477,7 @@ namespace { } // Only inline instruction it if it's use is in the same BB as the inst. -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) return I.getParent() == llvm::cast(I.user_back())->getParent(); #else return I.getParent() == llvm::cast(I.use_back())->getParent(); @@ -1770,7 +1770,7 @@ std::string CWriter::GetValueName(const llvm::Value *Operand) { // Resolve potential alias. if (const llvm::GlobalAlias *GA = llvm::dyn_cast(Operand)) { -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) if (const llvm::Value *V = GA->getAliasee()) #else if (const llvm::Value *V = GA->resolveAliasedGlobal(false)) @@ -2163,7 +2163,7 @@ static SpecialGlobalClass getGlobalVariableClass(const llvm::GlobalVariable *GV) // Otherwise, if it is other metadata, don't print it. This catches things // like debug information. -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) // Here we compare char * if (!strcmp(GV->getSection(), "llvm.metadata")) #else @@ -2225,7 +2225,7 @@ bool CWriter::doInitialization(llvm::Module &M) { #endif TAsm = new CBEMCAsmInfo(); MRI = new llvm::MCRegisterInfo(); -#if defined(LLVM_3_4) || defined(LLVM_3_5) +#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) TCtx = new llvm::MCContext(TAsm, MRI, NULL); #else TCtx = new llvm::MCContext(*TAsm, *MRI, NULL); @@ -2349,7 +2349,7 @@ bool CWriter::doInitialization(llvm::Module &M) { if (I->hasExternalLinkage() || I->hasExternalWeakLinkage() || I->hasCommonLinkage()) Out << "extern "; -#if defined (LLVM_3_5) +#if defined (LLVM_3_5) || defined(LLVM_3_6) else if (I->hasDLLImportStorageClass()) #else else if (I->hasDLLImportLinkage()) @@ -2525,7 +2525,7 @@ bool CWriter::doInitialization(llvm::Module &M) { if (I->hasLocalLinkage()) Out << "static "; -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) else if (I->hasDLLImportStorageClass()) Out << "__declspec(dllimport) "; else if (I->hasDLLExportStorageClass()) Out << "__declspec(dllexport) "; #else @@ -2810,7 +2810,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) { bool isStructReturn = F->hasStructRetAttr(); if (F->hasLocalLinkage()) Out << "static "; -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) if (F->hasDLLImportStorageClass()) Out << "__declspec(dllimport) "; if (F->hasDLLExportStorageClass()) Out << "__declspec(dllexport) "; #else @@ -3145,7 +3145,7 @@ void CWriter::visitSwitchInst(llvm::SwitchInst &SI) { Out << ":\n"; printPHICopiesForSuccessor (SI.getParent(), Succ, 2); printBranchToBlock(SI.getParent(), Succ, 2); -#if defined (LLVM_3_5) +#if defined (LLVM_3_5) || defined(LLVM_3_6) if (llvm::Function::iterator(Succ) == std::next(llvm::Function::iterator(SI.getParent()))) #else if (llvm::Function::iterator(Succ) == llvm::next(llvm::Function::iterator(SI.getParent()))) @@ -3170,7 +3170,7 @@ bool CWriter::isGotoCodeNecessary(llvm::BasicBlock *From, llvm::BasicBlock *To) /// FIXME: This should be reenabled, but loop reordering safe!! return true; -#if defined (LLVM_3_5) +#if defined (LLVM_3_5) || defined(LLVM_3_6) if (std::next(llvm::Function::iterator(From)) != llvm::Function::iterator(To)) #else if (llvm::next(llvm::Function::iterator(From)) != llvm::Function::iterator(To)) @@ -3788,7 +3788,7 @@ void CWriter::lowerIntrinsics(llvm::Function &F) { // All other intrinsic calls we must lower. llvm::Instruction *Before = 0; if (CI != &BB->front()) -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) Before = std::prev(llvm::BasicBlock::iterator(CI)); #else Before = prior(llvm::BasicBlock::iterator(CI)); diff --git a/ctx.cpp b/ctx.cpp index 57cbe7ae..8026c10a 100644 --- a/ctx.cpp +++ b/ctx.cpp @@ -352,7 +352,7 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym, AssertPos(currentPos, diSubprogramType.Verify()); } -#if defined(LLVM_3_4) || defined(LLVM_3_5) +#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) Assert(diSubprogramType.isCompositeType()); llvm::DICompositeType diSubprogramType_n = static_cast(diSubprogramType); @@ -1546,7 +1546,7 @@ FunctionEmitContext::StartScope() { llvm::DILexicalBlock lexicalBlock = m->diBuilder->createLexicalBlock(parentScope, diFile, currentPos.first_line, -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) // Revision 202736 in LLVM adds support of DWARF discriminator // to the last argument and revision 202737 in clang adds 0 // for the last argument by default. diff --git a/ctx.h b/ctx.h index f47777ff..3b9ce86a 100644 --- a/ctx.h +++ b/ctx.h @@ -47,7 +47,7 @@ #include #include #endif -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) #include #include #else diff --git a/expr.cpp b/expr.cpp index 8fa64f91..aeb8b670 100644 --- a/expr.cpp +++ b/expr.cpp @@ -74,7 +74,7 @@ #include #endif #include -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) #include #else #include diff --git a/func.cpp b/func.cpp index 82df6b27..1c92d112 100644 --- a/func.cpp +++ b/func.cpp @@ -69,7 +69,7 @@ #include #include #include -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) #include #include #include @@ -478,7 +478,7 @@ Function::GenerateIR() { } if (m->errorCount == 0) { -#if defined (LLVM_3_5) +#if defined (LLVM_3_5) || defined(LLVM_3_6) if (llvm::verifyFunction(*function) == true) { #else if (llvm::verifyFunction(*function, llvm::ReturnStatusAction) == true) { @@ -528,7 +528,7 @@ Function::GenerateIR() { emitCode(&ec, appFunction, firstStmtPos); if (m->errorCount == 0) { sym->exportedFunction = appFunction; -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) if (llvm::verifyFunction(*appFunction) == true) { #else if (llvm::verifyFunction(*appFunction, diff --git a/ispc.cpp b/ispc.cpp index 8e029502..913a2d99 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -57,7 +57,7 @@ #include #include #endif -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) #include #include #else diff --git a/ispc.h b/ispc.h index 86be754c..29925e46 100644 --- a/ispc.h +++ b/ispc.h @@ -40,8 +40,8 @@ #define ISPC_VERSION "1.7.1dev" -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) -#error "Only LLVM 3.1, 3.2, 3.3, 3.4 and the 3.5 development branch are supported" +#if !defined(LLVM_3_1) && !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) && !defined(LLVM_3_6) +#error "Only LLVM 3.1, 3.2, 3.3, 3.4, 3.5 and the 3.6 development branch are supported" #endif #if defined(_WIN32) || defined(_WIN64) diff --git a/main.cpp b/main.cpp index 99497af5..97dec095 100644 --- a/main.cpp +++ b/main.cpp @@ -72,6 +72,8 @@ lPrintVersion() { "3.4" #elif defined(LLVM_3_5) "3.5" +#elif defined(LLVM_3_6) + "3.6" #else #error "Unhandled LLVM version" #endif @@ -166,7 +168,7 @@ devUsage(int ret) { printf(" disable-uniform-memory-optimizations\tDisable uniform-based coherent memory access\n"); printf(" [--yydebug]\t\t\t\tPrint debugging information during parsing\n"); printf(" [--debug-phase=]\t\tSet optimization phases to dump. --debug-phase=first,210:220,300,305,310:last\n"); -#if defined(LLVM_3_4) || defined(LLVM_3_5) +#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) printf(" [--debug-ir=]\t\tSet optimization phase to generate debugIR after it\n"); #endif printf(" [--off-phase=]\t\tSwitch off optimization phases. --off-phase=first,210:220,300,305,310:last\n"); @@ -549,7 +551,7 @@ int main(int Argc, char *Argv[]) { "away or introduce the new ones.\n"); g->debug_stages = ParsingPhases(argv[i] + strlen("--debug-phase=")); } -#if defined(LLVM_3_4) || defined(LLVM_3_5) +#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) else if (strncmp(argv[i], "--debug-ir=", 11) == 0) { g->debugIR = ParsingPhaseName(argv[i] + strlen("--debug-ir=")); } diff --git a/module.cpp b/module.cpp index b5fd860c..ce7e6bde 100644 --- a/module.cpp +++ b/module.cpp @@ -93,7 +93,7 @@ #include #include #endif -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) #include #include #include @@ -948,7 +948,7 @@ Module::writeOutput(OutputType outputType, const char *outFileName, lStripUnusedDebugInfo(module); } -#if defined (LLVM_3_4) || defined (LLVM_3_5) +#if defined (LLVM_3_4) || defined (LLVM_3_5) || defined(LLVM_3_6) // In LLVM_3_4 after r195494 and r195504 revisions we should pass // "Debug Info Version" constant to the module. LLVM will ignore // our Debug Info metadata without it. @@ -1105,7 +1105,7 @@ Module::writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine, } llvm::PassManager pm; -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) pm.add(new llvm::DataLayoutPass(*g->target->getDataLayout())); #else pm.add(new llvm::DataLayout(*g->target->getDataLayout())); @@ -2114,7 +2114,7 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre } inst.getLangOpts().LineComment = 1; -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) inst.createPreprocessor(clang::TU_Complete); #else inst.createPreprocessor(); diff --git a/module.h b/module.h index c1350063..7575457f 100644 --- a/module.h +++ b/module.h @@ -44,7 +44,7 @@ #if defined(LLVM_3_4) #include #endif -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) #include #endif diff --git a/opt.cpp b/opt.cpp index 7b955a2c..a42a2268 100644 --- a/opt.cpp +++ b/opt.cpp @@ -63,12 +63,12 @@ #include #include #endif -#if defined (LLVM_3_4) || defined(LLVM_3_5) +#if defined (LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) #include #endif #include #include -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) #include #include #include @@ -444,7 +444,7 @@ DebugPassManager::add(llvm::Pass * P, int stage = -1) { number, P->getPassName()); PM.add(CreateDebugPass(buf)); } -#if defined(LLVM_3_4) || defined(LLVM_3_5) +#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) if (g->debugIR == number) { // adding generating of LLVM IR debug after optimization char buf[100]; @@ -469,7 +469,7 @@ Optimize(llvm::Module *module, int optLevel) { new llvm::TargetLibraryInfo(llvm::Triple(module->getTargetTriple())); optPM.add(targetLibraryInfo); -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) optPM.add(new llvm::DataLayoutPass(*g->target->getDataLayout())); #else optPM.add(new llvm::DataLayout(*g->target->getDataLayout())); diff --git a/type.cpp b/type.cpp index 9e8ef131..57d448d8 100644 --- a/type.cpp +++ b/type.cpp @@ -50,7 +50,7 @@ #include #include #endif -#if defined(LLVM_3_5) +#if defined(LLVM_3_5) || defined(LLVM_3_6) #include #include #else @@ -2987,7 +2987,7 @@ FunctionType::GetDIType(llvm::DIDescriptor scope) const { for (int i = 0; i < GetNumParameters(); ++i) { const Type *t = GetParameterType(i); if (t == NULL) -#if defined(LLVM_3_4) || defined(LLVM_3_5) +#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) return llvm::DICompositeType(); #else return llvm::DIType(); From f59a1db8b792b56d81f65cdeb740afba529dfd13 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Wed, 30 Jul 2014 13:57:06 +0400 Subject: [PATCH 26/50] fixed 3.6 llvm build in type.cpp --- alloy.py | 15 ++++++++++----- docs/ReleaseNotes.txt | 3 ++- type.cpp | 7 ++++++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/alloy.py b/alloy.py index 6fcfca96..4adb060d 100755 --- a/alloy.py +++ b/alloy.py @@ -111,6 +111,9 @@ def build_LLVM(version_LLVM, revision, folder, tarball, debug, selfbuild, extra, FOLDER_NAME=version_LLVM if version_LLVM == "trunk": SVN_PATH="trunk" + if version_LLVM == "3.5": + SVN_PATH="tags/RELEASE_35/rc1" + version_LLVM = "3_5" if version_LLVM == "3.4": SVN_PATH="tags/RELEASE_34/dot2-final" version_LLVM = "3_4" @@ -351,8 +354,10 @@ def build_ispc(version_LLVM, make): temp = "3_3" if version_LLVM == "3.4": temp = "3_4" - if version_LLVM == "trunk": + if version_LLVM == "3.5": temp = "3_5" + if version_LLVM == "trunk": + temp = "3_6" os.environ["LLVM_VERSION"] = "LLVM_" + temp try_do_LLVM("clean ISPC for building", "msbuild ispc.vcxproj /t:clean", True) try_do_LLVM("build ISPC with LLVM version " + version_LLVM + " ", "msbuild ispc.vcxproj /V:m /p:Platform=Win32 /p:Configuration=Release /t:rebuild", True) @@ -454,7 +459,7 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, archs.append("x86-64") if "native" in only: sde_targets_t = [] - for i in ["3.1", "3.2", "3.3", "3.4", "trunk"]: + for i in ["3.1", "3.2", "3.3", "3.4", "3.5", "trunk"]: if i in only: LLVM.append(i) if "current" in only: @@ -707,7 +712,7 @@ def Main(): if os.environ.get("SMTP_ISPC") == None: error("you have no SMTP_ISPC in your environment for option notify", 1) if options.only != "": - test_only_r = " 3.1 3.2 3.3 3.4 trunk current build stability performance x86 x86-64 -O0 -O2 native " + test_only_r = " 3.1 3.2 3.3 3.4 3.5 trunk current build stability performance x86 x86-64 -O0 -O2 native " test_only = options.only.split(" ") for iterator in test_only: if not (" " + iterator + " " in test_only_r): @@ -816,7 +821,7 @@ if __name__ == '__main__': llvm_group = OptionGroup(parser, "Options for building LLVM", "These options must be used with -b option.") llvm_group.add_option('--version', dest='version', - help='version of llvm to build: 3.1 3.2 3.3 3.4 trunk. Default: trunk', default="trunk") + help='version of llvm to build: 3.1 3.2 3.3 3.4 3.5 trunk. Default: trunk', default="trunk") llvm_group.add_option('--revision', dest='revision', help='revision of llvm to build in format r172870', default="") llvm_group.add_option('--debug', dest='debug', @@ -851,7 +856,7 @@ if __name__ == '__main__': run_group.add_option('--only', dest='only', help='set types of tests. Possible values:\n' + '-O0, -O2, x86, x86-64, stability (test only stability), performance (test only performance)\n' + - 'build (only build with different LLVM), 3.1, 3.2, 3.3, 3.4, trunk, native (do not use SDE), current (do not rebuild ISPC).', + 'build (only build with different LLVM), 3.1, 3.2, 3.3, 3.4 3.5, trunk, native (do not use SDE), current (do not rebuild ISPC).', default="") run_group.add_option('--perf_LLVM', dest='perf_llvm', help='compare LLVM 3.3 with "--compare-with", default trunk', default=False, action='store_true') diff --git a/docs/ReleaseNotes.txt b/docs/ReleaseNotes.txt index ef8cf6f8..7b76dd4c 100644 --- a/docs/ReleaseNotes.txt +++ b/docs/ReleaseNotes.txt @@ -77,7 +77,8 @@ If you are not using pre-built binaries, you may notice the following changes: This is a preferred way to build LLVM for ISPC, as all required patches for better performance and stability will automatically apply. -* LLVM 3.5 (current trunk) is supported. +* LLVM 3.5 is supported. +* LLVM 3.6 (current trunk) is supported. There are also multiple fixes for better performance and stability, most notable are: diff --git a/type.cpp b/type.cpp index 57d448d8..9579ebba 100644 --- a/type.cpp +++ b/type.cpp @@ -2994,9 +2994,14 @@ FunctionType::GetDIType(llvm::DIDescriptor scope) const { #endif retArgTypes.push_back(t->GetDIType(scope)); } - +#if defined(LLVM_3_6) + llvm::DITypeArray retArgTypesArray = + m->diBuilder->getOrCreateTypeArray(llvm::ArrayRef(retArgTypes)); +#else llvm::DIArray retArgTypesArray = m->diBuilder->getOrCreateArray(llvm::ArrayRef(retArgTypes)); +#endif + llvm::DIType diType = // FIXME: DIFile m->diBuilder->createSubroutineType(llvm::DIFile(), retArgTypesArray); From c0fc9b7aca07f828877531d280462802ea2347cb Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Wed, 30 Jul 2014 15:15:15 +0400 Subject: [PATCH 27/50] removed duplicatees in Makefile --- Makefile | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index fb93e324..412fc252 100644 --- a/Makefile +++ b/Makefile @@ -113,11 +113,9 @@ ifeq ($(LLVM_VERSION),LLVM_3_4) ISPC_LIBS += -lcurses endif -ifeq ($(LLVM_VERSION),LLVM_3_5) - ISPC_LIBS += -lcurses -lz -endif - -ifeq ($(LLVM_VERSION),LLVM_3_6) +# There is no logical OR in GNU make. +# This 'ifneq' acts like if($(LLVM_VERSION) == LLVM_3_5 || $(LLVM_VERSION) == LLVM_3_6) +ifneq (,$(filter $(LLVM_VERSION), LLVM_3_5 LLVM_3_6)) ISPC_LIBS += -lcurses -lz endif @@ -154,10 +152,9 @@ CXXFLAGS=$(OPT) $(LLVM_CXXFLAGS) -I. -Iobjs/ -I$(CLANG_INCLUDE) \ -Wall \ -DBUILD_DATE="\"$(BUILD_DATE)\"" -DBUILD_VERSION="\"$(BUILD_VERSION)\"" \ -Wno-sign-compare -Wno-unused-function -Werror -ifeq ($(LLVM_VERSION),LLVM_3_5) - CXXFLAGS+=-std=c++11 -Wno-c99-extensions -Wno-deprecated-register -endif -ifeq ($(LLVM_VERSION),LLVM_3_6) + +# if($(LLVM_VERSION) == LLVM_3_5 || $(LLVM_VERSION) == LLVM_3_6) +ifneq (,$(filter $(LLVM_VERSION), LLVM_3_5 LLVM_3_6)) CXXFLAGS+=-std=c++11 -Wno-c99-extensions -Wno-deprecated-register endif ifneq ($(ARM_ENABLED), 0) From 71717015999801b11991a9bb4828c0c7182a4d95 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Wed, 30 Jul 2014 16:25:39 +0400 Subject: [PATCH 28/50] checked Makefile 'if' constructions, fixed ReleaseNotes.txt, added comments to util.m4 --- builtins/util.m4 | 4 ++-- docs/ReleaseNotes.txt | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/builtins/util.m4 b/builtins/util.m4 index 52c642b4..0ea7763e 100644 --- a/builtins/util.m4 +++ b/builtins/util.m4 @@ -1500,7 +1500,7 @@ define <$1 x $2> @__atomic_compare_exchange_$3_global($2* %ptr, <$1 x $2> %cmp, ifelse(LLVM_VERSION,LLVM_3_5,` %r_LANE_ID_t = cmpxchg $2 * %ptr, $2 %cmp_LANE_ID, $2 %val_LANE_ID seq_cst seq_cst %r_LANE_ID = extractvalue { $2, i1 } %r_LANE_ID_t, 0 - ',LLVM_VERSION,LLVM_3_6,` + ',LLVM_VERSION,LLVM_3_6,` ; this is duplicated for 3.6 since m4 has no OR and AND operators %r_LANE_ID_t = cmpxchg $2 * %ptr, $2 %cmp_LANE_ID, $2 %val_LANE_ID seq_cst seq_cst %r_LANE_ID = extractvalue { $2, i1 } %r_LANE_ID_t, 0 ',` @@ -1518,7 +1518,7 @@ define $2 @__atomic_compare_exchange_uniform_$3_global($2* %ptr, $2 %cmp, ifelse(LLVM_VERSION,LLVM_3_5,` %r_t = cmpxchg $2 * %ptr, $2 %cmp, $2 %val seq_cst seq_cst %r = extractvalue { $2, i1 } %r_t, 0 - ',LLVM_VERSION,LLVM_3_6,` + ',LLVM_VERSION,LLVM_3_6,` ; this is duplicated for 3.6 since m4 has no OR and AND operators %r_t = cmpxchg $2 * %ptr, $2 %cmp, $2 %val seq_cst seq_cst %r = extractvalue { $2, i1 } %r_t, 0 ',` diff --git a/docs/ReleaseNotes.txt b/docs/ReleaseNotes.txt index 7b76dd4c..ef8cf6f8 100644 --- a/docs/ReleaseNotes.txt +++ b/docs/ReleaseNotes.txt @@ -77,8 +77,7 @@ If you are not using pre-built binaries, you may notice the following changes: This is a preferred way to build LLVM for ISPC, as all required patches for better performance and stability will automatically apply. -* LLVM 3.5 is supported. -* LLVM 3.6 (current trunk) is supported. +* LLVM 3.5 (current trunk) is supported. There are also multiple fixes for better performance and stability, most notable are: From 368d2f18f9dd485796a90316dee260ae28912a8b Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Wed, 30 Jul 2014 16:43:41 +0400 Subject: [PATCH 29/50] rewritten comment for util.m4 --- builtins/util.m4 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/builtins/util.m4 b/builtins/util.m4 index 0ea7763e..73998ddc 100644 --- a/builtins/util.m4 +++ b/builtins/util.m4 @@ -1497,10 +1497,12 @@ define <$1 x $2> @__atomic_compare_exchange_$3_global($2* %ptr, <$1 x $2> %cmp, per_lane($1, <$1 x MASK> %mask, ` %cmp_LANE_ID = extractelement <$1 x $2> %cmp, i32 LANE %val_LANE_ID = extractelement <$1 x $2> %val, i32 LANE + + ;; 3.5 and 3.6 code is the same since m4 has no OR and AND operators ifelse(LLVM_VERSION,LLVM_3_5,` %r_LANE_ID_t = cmpxchg $2 * %ptr, $2 %cmp_LANE_ID, $2 %val_LANE_ID seq_cst seq_cst %r_LANE_ID = extractvalue { $2, i1 } %r_LANE_ID_t, 0 - ',LLVM_VERSION,LLVM_3_6,` ; this is duplicated for 3.6 since m4 has no OR and AND operators + ',LLVM_VERSION,LLVM_3_6,` %r_LANE_ID_t = cmpxchg $2 * %ptr, $2 %cmp_LANE_ID, $2 %val_LANE_ID seq_cst seq_cst %r_LANE_ID = extractvalue { $2, i1 } %r_LANE_ID_t, 0 ',` @@ -1514,11 +1516,12 @@ define <$1 x $2> @__atomic_compare_exchange_$3_global($2* %ptr, <$1 x $2> %cmp, } define $2 @__atomic_compare_exchange_uniform_$3_global($2* %ptr, $2 %cmp, - $2 %val) nounwind alwaysinline { + $2 %val) nounwind alwaysinline { + ;; 3.5 and 3.6 code is the same since m4 has no OR and AND operators ifelse(LLVM_VERSION,LLVM_3_5,` %r_t = cmpxchg $2 * %ptr, $2 %cmp, $2 %val seq_cst seq_cst %r = extractvalue { $2, i1 } %r_t, 0 - ',LLVM_VERSION,LLVM_3_6,` ; this is duplicated for 3.6 since m4 has no OR and AND operators + ',LLVM_VERSION,LLVM_3_6,` %r_t = cmpxchg $2 * %ptr, $2 %cmp, $2 %val seq_cst seq_cst %r = extractvalue { $2, i1 } %r_t, 0 ',` From ce7a00d174a59e77af0d90425f47548884ad6faa Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Fri, 1 Aug 2014 12:21:50 +0400 Subject: [PATCH 30/50] update fail_db for 3.6 --- fail_db.txt | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/fail_db.txt b/fail_db.txt index e45578d1..9def9b6c 100644 --- a/fail_db.txt +++ b/fail_db.txt @@ -336,3 +336,121 @@ ./tests/reduce-equal-5.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * ./tests/reduce-equal-6.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * ./tests/reduce-equal-8.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * +./tests/masked-scatter-struct.ispc runfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O2 * +./tests/exclusive-scan-add-1.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O2 * +./tests/exclusive-scan-add-10.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O2 * +./tests/exclusive-scan-add-2.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O2 * +./tests/exclusive-scan-add-5.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O2 * +./tests/exclusive-scan-add-6.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O2 * +./tests/exclusive-scan-add-7.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O2 * +./tests/ptr-assign-lhs-math-1.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O2 * +./tests/short-vec-8.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O2 * +./tests/half-1.ispc runfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/ptr-15.ispc runfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/atomics-1.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/atomics-10.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/atomics-11.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/atomics-12.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/atomics-13.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/atomics-14.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/atomics-2.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/atomics-3.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/atomics-4.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/atomics-9.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/exclusive-scan-add-1.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/exclusive-scan-add-10.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/exclusive-scan-add-8.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/exclusive-scan-add-9.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/exclusive-scan-and-1.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/exclusive-scan-and-2.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/exclusive-scan-or-1.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/reduce-equal-1.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/reduce-equal-10.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/reduce-equal-12.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/reduce-equal-13.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/reduce-equal-2.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/reduce-equal-3.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/reduce-equal-4.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/reduce-equal-5.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/reduce-equal-6.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/reduce-equal-8.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/short-vec-8.ispc compfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/test-143.ispc runfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O2 * +./tests/ptr-assign-lhs-math-1.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O2 * +./tests/half-1.ispc runfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/ptr-15.ispc runfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/ptr-19.ispc runfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/test-143.ispc runfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/atomics-1.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/atomics-10.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/atomics-11.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/atomics-12.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/atomics-13.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/atomics-14.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/atomics-2.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/atomics-3.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/atomics-4.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/atomics-9.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/exclusive-scan-add-1.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/exclusive-scan-add-10.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/exclusive-scan-add-8.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/exclusive-scan-add-9.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/exclusive-scan-and-1.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/exclusive-scan-and-2.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/exclusive-scan-or-1.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/reduce-equal-1.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/reduce-equal-10.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/reduce-equal-12.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/reduce-equal-13.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/reduce-equal-2.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/reduce-equal-3.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/reduce-equal-4.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/reduce-equal-5.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/reduce-equal-6.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/reduce-equal-8.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +.\tests\foreach-double-1.ispc runfail x86 avx2-i32x8 Windows LLVM 3.6 cl -O2 * +.\tests\foreach-double-1.ispc runfail x86 avx2-i32x16 Windows LLVM 3.6 cl -O2 * +.\tests\foreach-double-1.ispc runfail x86 avx2-i64x4 Windows LLVM 3.6 cl -O2 * +./tests/ptr-22.ispc runfail x86-64 generic-4 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/ptr-22.ispc runfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * +./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * +./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * +./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * +./tests/paddus_vi16.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * +./tests/paddus_vi8.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * +./tests/pmuls_i64.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * +./tests/pmulus_i16.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * +./tests/pmulus_i32.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * +./tests/pmulus_i64.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * +./tests/pmulus_i8.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * +./tests/ptr-assign-lhs-math-1.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * +./tests/atomics-1.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/atomics-10.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/atomics-11.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/atomics-12.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/atomics-13.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/atomics-14.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/atomics-2.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/atomics-3.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/atomics-4.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/atomics-9.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/exclusive-scan-add-1.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/exclusive-scan-add-10.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/exclusive-scan-add-8.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/exclusive-scan-add-9.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/exclusive-scan-and-1.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/exclusive-scan-and-2.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/exclusive-scan-or-1.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/reduce-equal-1.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/reduce-equal-10.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/reduce-equal-12.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/reduce-equal-13.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/reduce-equal-2.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/reduce-equal-3.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/reduce-equal-4.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/reduce-equal-5.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/reduce-equal-6.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * +./tests/reduce-equal-8.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * From 10c6f840c4bbdc0dbd8a0185452c2c2cb4989f46 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Fri, 1 Aug 2014 12:30:57 +0400 Subject: [PATCH 31/50] removed 'llvm/Config/config.h' from cbackend.cpp build for LLVM 3.5+ --- cbackend.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cbackend.cpp b/cbackend.cpp index aa7a9aca..c2f8a035 100644 --- a/cbackend.cpp +++ b/cbackend.cpp @@ -107,7 +107,10 @@ #include "llvm/Support/TargetRegistry.h" #include "llvm/Support/Host.h" #include "llvm/Target/TargetMachine.h" -#include "llvm/Config/config.h" + +#if defined(LLVM_3_1) || defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) + #include "llvm/Config/config.h" +#endif #include #include From d0c9b7c9b5313fa8b92cac2197354767aa9f40f3 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Fri, 1 Aug 2014 14:54:08 +0400 Subject: [PATCH 32/50] wiped out all LLVM 3.1 support --- builtins.cpp | 4 +- builtins/dispatch.ll | 2 - builtins/target-avx11-i64x4.ll | 3 +- builtins/target-avx11-x2.ll | 9 +- builtins/target-avx11.ll | 9 +- builtins/target-avx2-i64x4.ll | 17 +--- builtins/target-avx2-x2.ll | 29 +----- builtins/target-avx2.ll | 30 +----- builtins/target-generic-common.ll | 16 +-- builtins/util.m4 | 156 +++++------------------------- cbackend.cpp | 140 +++++++++------------------ ctx.cpp | 8 +- ctx.h | 2 +- expr.cpp | 12 +-- func.cpp | 11 +-- ispc.cpp | 30 ++---- ispc.h | 19 +--- ispc.vcxproj | 4 +- llvmutil.cpp | 2 +- llvmutil.h | 2 +- main.cpp | 4 +- module.cpp | 45 +++------ module.h | 2 +- opt.cpp | 12 +-- parse.yy | 2 +- stmt.cpp | 2 +- type.cpp | 12 +-- type.h | 2 +- util.cpp | 10 +- 29 files changed, 136 insertions(+), 460 deletions(-) diff --git a/builtins.cpp b/builtins.cpp index 377f4f50..56b69447 100644 --- a/builtins.cpp +++ b/builtins.cpp @@ -50,7 +50,7 @@ #if defined(LLVM_3_2) #include #endif -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #include @@ -853,7 +853,7 @@ lDefineConstantIntFunc(const char *name, int val, llvm::Module *module, Assert(func != NULL); // it should be declared already... #if defined(LLVM_3_2) func->addFnAttr(llvm::Attributes::AlwaysInline); -#else // LLVM 3.1 and 3.3+ +#else // LLVM 3.3+ func->addFnAttr(llvm::Attribute::AlwaysInline); #endif llvm::BasicBlock *bblock = llvm::BasicBlock::Create(*g->ctx, "entry", func, 0); diff --git a/builtins/dispatch.ll b/builtins/dispatch.ll index ba216df7..4a4cd1fc 100644 --- a/builtins/dispatch.ll +++ b/builtins/dispatch.ll @@ -46,8 +46,6 @@ ;; corresponding to one of the Target::ISA enumerant values that gives the ;; most capable ISA that the curremt system can run. ;; -;; Note: clang from LLVM 3.1 should be used if this is updated, for maximum -;; backwards compatibility for anyone building ispc with LLVM 3.1 ;; ;; #include ;; #include diff --git a/builtins/target-avx11-i64x4.ll b/builtins/target-avx11-i64x4.ll index 8fe75266..41379798 100644 --- a/builtins/target-avx11-i64x4.ll +++ b/builtins/target-avx11-i64x4.ll @@ -31,8 +31,7 @@ include(`target-avx1-i64x4base.ll') -ifelse(LLVM_VERSION, `LLVM_3_1', `rdrand_decls()', - `rdrand_definition()') +rdrand_definition() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; int min/max diff --git a/builtins/target-avx11-x2.ll b/builtins/target-avx11-x2.ll index 3da9c890..df3e26b4 100644 --- a/builtins/target-avx11-x2.ll +++ b/builtins/target-avx11-x2.ll @@ -31,9 +31,7 @@ include(`target-avx-x2.ll') -ifelse(LLVM_VERSION, `LLVM_3_0', `rdrand_decls()', - LLVM_VERSION, `LLVM_3_1', `rdrand_decls()', - `rdrand_definition()') +rdrand_definition() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; int min/max @@ -75,9 +73,6 @@ gen_gather(double) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; float/half conversions -ifelse(LLVM_VERSION, `LLVM_3_0', ` -;; nothing to define... -', ` declare <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16>) nounwind readnone ; 0 is round nearest even declare <8 x i16> @llvm.x86.vcvtps2ph.256(<8 x float>, i32) nounwind readnone @@ -128,5 +123,3 @@ define i16 @__float_to_half_uniform(float %v) nounwind readnone { %r = extractelement <8 x i16> %rv, i32 0 ret i16 %r } -' -) diff --git a/builtins/target-avx11.ll b/builtins/target-avx11.ll index dd615779..0d744cad 100644 --- a/builtins/target-avx11.ll +++ b/builtins/target-avx11.ll @@ -31,10 +31,7 @@ include(`target-avx.ll') -ifelse(LLVM_VERSION, `LLVM_3_0', `rdrand_decls()', - LLVM_VERSION, `LLVM_3_1', `rdrand_decls()', - `rdrand_definition()') - +rdrand_definition() saturation_arithmetic() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -77,9 +74,6 @@ gen_gather(double) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; float/half conversions -ifelse(LLVM_VERSION, `LLVM_3_0', ` -;; nothing to define... -', ` declare <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16>) nounwind readnone ; 0 is round nearest even declare <8 x i16> @llvm.x86.vcvtps2ph.256(<8 x float>, i32) nounwind readnone @@ -114,4 +108,3 @@ define i16 @__float_to_half_uniform(float %v) nounwind readnone { %r = extractelement <8 x i16> %rv, i32 0 ret i16 %r } -') diff --git a/builtins/target-avx2-i64x4.ll b/builtins/target-avx2-i64x4.ll index d74f32dc..47f42fc2 100644 --- a/builtins/target-avx2-i64x4.ll +++ b/builtins/target-avx2-i64x4.ll @@ -29,13 +29,11 @@ ;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -ifelse(LLVM_VERSION, `LLVM_3_1', `', - `define(`HAVE_GATHER', `1')') +define(`HAVE_GATHER', `1') include(`target-avx1-i64x4base.ll') -ifelse(LLVM_VERSION, `LLVM_3_1', `rdrand_decls()', - `rdrand_definition()') +rdrand_definition() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; int min/max @@ -126,15 +124,6 @@ define i16 @__float_to_half_uniform(float %v) nounwind readnone { declare void @llvm.trap() noreturn nounwind - -ifelse(LLVM_VERSION, `LLVM_3_1', ` -gen_gather_factored(i8) -gen_gather_factored(i16) -gen_gather_factored(i32) -gen_gather_factored(float) -gen_gather_factored(i64) -gen_gather_factored(double)', ` - gen_gather(i8) gen_gather(i16) @@ -351,5 +340,3 @@ define <4 x double> @__gather64_double(<4 x i64> %ptrs, ret <4 x double> %v } - -') diff --git a/builtins/target-avx2-x2.ll b/builtins/target-avx2-x2.ll index 4eb6720e..abc39885 100644 --- a/builtins/target-avx2-x2.ll +++ b/builtins/target-avx2-x2.ll @@ -29,15 +29,11 @@ ;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -ifelse(LLVM_VERSION, `LLVM_3_0', `', - LLVM_VERSION, `LLVM_3_1', `', - `define(`HAVE_GATHER', `1')') +define(`HAVE_GATHER', `1') include(`target-avx-x2.ll') -ifelse(LLVM_VERSION, `LLVM_3_0', `rdrand_decls()', - LLVM_VERSION, `LLVM_3_1', `rdrand_decls()', - `rdrand_definition()') +rdrand_definition() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; int min/max @@ -74,9 +70,6 @@ define <16 x i32> @__max_varying_uint32(<16 x i32>, <16 x i32>) nounwind readonl ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; float/half conversions -ifelse(LLVM_VERSION, `LLVM_3_0', ` -;; nothing to define... -', ` declare <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16>) nounwind readnone ; 0 is round nearest even declare <8 x i16> @llvm.x86.vcvtps2ph.256(<8 x float>, i32) nounwind readnone @@ -127,7 +120,7 @@ define i16 @__float_to_half_uniform(float %v) nounwind readnone { %r = extractelement <8 x i16> %rv, i32 0 ret i16 %r } -') + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; gather @@ -176,20 +169,6 @@ define(`assemble_4s', ` assemble_8s($1, $2, $2_1, $2_2) ') -ifelse(LLVM_VERSION, `LLVM_3_0', ` -gen_gather_factored(i8) -gen_gather_factored(i16) -gen_gather_factored(i32) -gen_gather_factored(float) -gen_gather_factored(i64) -gen_gather_factored(double)', -LLVM_VERSION, `LLVM_3_1', ` -gen_gather_factored(i8) -gen_gather_factored(i16) -gen_gather_factored(i32) -gen_gather_factored(float) -gen_gather_factored(i64) -gen_gather_factored(double)', ` gen_gather(i8) gen_gather(i16) @@ -557,5 +536,3 @@ define <16 x double> @__gather64_double(<16 x i64> %ptrs, ret <16 x double> %v } - -') diff --git a/builtins/target-avx2.ll b/builtins/target-avx2.ll index c9e21e65..dc7bca2a 100644 --- a/builtins/target-avx2.ll +++ b/builtins/target-avx2.ll @@ -29,16 +29,11 @@ ;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -ifelse(LLVM_VERSION, `LLVM_3_0', `', - LLVM_VERSION, `LLVM_3_1', `', - `define(`HAVE_GATHER', `1')') +define(`HAVE_GATHER', `1') include(`target-avx.ll') -ifelse(LLVM_VERSION, `LLVM_3_0', `rdrand_decls()', - LLVM_VERSION, `LLVM_3_1', `rdrand_decls()', - `rdrand_definition()') - +rdrand_definition() saturation_arithmetic() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -76,9 +71,6 @@ define <8 x i32> @__max_varying_uint32(<8 x i32>, <8 x i32>) nounwind readonly a ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; float/half conversions -ifelse(LLVM_VERSION, `LLVM_3_0', ` -;; nothing to define... -', ` declare <8 x float> @llvm.x86.vcvtph2ps.256(<8 x i16>) nounwind readnone ; 0 is round nearest even declare <8 x i16> @llvm.x86.vcvtps2ph.256(<8 x float>, i32) nounwind readnone @@ -113,7 +105,6 @@ define i16 @__float_to_half_uniform(float %v) nounwind readnone { %r = extractelement <8 x i16> %rv, i32 0 ret i16 %r } -') ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; gather @@ -125,21 +116,6 @@ define(`extract_4s', ` %$2_2 = shufflevector <8 x $1> %$2, <8 x $1> undef, <4 x i32> ') -ifelse(LLVM_VERSION, `LLVM_3_0', ` -gen_gather_factored(i8) -gen_gather_factored(i16) -gen_gather_factored(i32) -gen_gather_factored(float) -gen_gather_factored(i64) -gen_gather_factored(double)', -LLVM_VERSION, `LLVM_3_1', ` -gen_gather_factored(i8) -gen_gather_factored(i16) -gen_gather_factored(i32) -gen_gather_factored(float) -gen_gather_factored(i64) -gen_gather_factored(double)', ` - gen_gather(i8) gen_gather(i16) @@ -431,5 +407,3 @@ define <8 x double> @__gather64_double(<8 x i64> %ptrs, ret <8 x double> %v } - -') diff --git a/builtins/target-generic-common.ll b/builtins/target-generic-common.ll index 8b651159..225c2681 100644 --- a/builtins/target-generic-common.ll +++ b/builtins/target-generic-common.ll @@ -275,20 +275,7 @@ declare void @__masked_store_i64(* nocapture, , declare void @__masked_store_double(* nocapture, , %mask) nounwind -ifelse(LLVM_VERSION, `LLVM_3_0', ` -declare void @__masked_store_blend_i8(* nocapture, , - ) nounwind -declare void @__masked_store_blend_i16(* nocapture, , - ) nounwind -declare void @__masked_store_blend_i32(* nocapture, , - ) nounwind -declare void @__masked_store_blend_float(* nocapture, , - ) nounwind -declare void @__masked_store_blend_i64(* nocapture, , - %mask) nounwind -declare void @__masked_store_blend_double(* nocapture, , - %mask) nounwind -', ` + define void @__masked_store_blend_i8(* nocapture, , ) nounwind alwaysinline { %v = load * %0 @@ -336,7 +323,6 @@ define void @__masked_store_blend_double(* nocapture, store %v1, * %0 ret void } -') ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; gather/scatter diff --git a/builtins/util.m4 b/builtins/util.m4 index 73998ddc..3a817a54 100644 --- a/builtins/util.m4 +++ b/builtins/util.m4 @@ -3922,23 +3922,10 @@ define(`masked_store_blend_8_16_by_4', ` define void @__masked_store_blend_i8(<4 x i8>* nocapture, <4 x i8>, <4 x i32>) nounwind alwaysinline { %old = load <4 x i8> * %0, align 1 - ifelse(LLVM_VERSION,LLVM_3_0,` - %old32 = bitcast <4 x i8> %old to i32 - %new32 = bitcast <4 x i8> %1 to i32 - - %mask8 = trunc <4 x i32> %2 to <4 x i8> - %mask32 = bitcast <4 x i8> %mask8 to i32 - %notmask32 = xor i32 %mask32, -1 - - %newmasked = and i32 %new32, %mask32 - %oldmasked = and i32 %old32, %notmask32 - %result = or i32 %newmasked, %oldmasked - - %resultvec = bitcast i32 %result to <4 x i8> - ',` - %m = trunc <4 x i32> %2 to <4 x i1> - %resultvec = select <4 x i1> %m, <4 x i8> %1, <4 x i8> %old - ') + + %m = trunc <4 x i32> %2 to <4 x i1> + %resultvec = select <4 x i1> %m, <4 x i8> %1, <4 x i8> %old + store <4 x i8> %resultvec, <4 x i8> * %0, align 1 ret void } @@ -3946,23 +3933,10 @@ define void @__masked_store_blend_i8(<4 x i8>* nocapture, <4 x i8>, define void @__masked_store_blend_i16(<4 x i16>* nocapture, <4 x i16>, <4 x i32>) nounwind alwaysinline { %old = load <4 x i16> * %0, align 2 - ifelse(LLVM_VERSION,LLVM_3_0,` - %old64 = bitcast <4 x i16> %old to i64 - %new64 = bitcast <4 x i16> %1 to i64 + + %m = trunc <4 x i32> %2 to <4 x i1> + %resultvec = select <4 x i1> %m, <4 x i16> %1, <4 x i16> %old - %mask16 = trunc <4 x i32> %2 to <4 x i16> - %mask64 = bitcast <4 x i16> %mask16 to i64 - %notmask64 = xor i64 %mask64, -1 - - %newmasked = and i64 %new64, %mask64 - %oldmasked = and i64 %old64, %notmask64 - %result = or i64 %newmasked, %oldmasked - - %resultvec = bitcast i64 %result to <4 x i16> - ',` - %m = trunc <4 x i32> %2 to <4 x i1> - %resultvec = select <4 x i1> %m, <4 x i16> %1, <4 x i16> %old - ') store <4 x i16> %resultvec, <4 x i16> * %0, align 2 ret void } @@ -3972,23 +3946,10 @@ define(`masked_store_blend_8_16_by_4_mask64', ` define void @__masked_store_blend_i8(<4 x i8>* nocapture, <4 x i8>, <4 x i64>) nounwind alwaysinline { %old = load <4 x i8> * %0, align 1 - ifelse(LLVM_VERSION,LLVM_3_0,` - %old32 = bitcast <4 x i8> %old to i32 - %new32 = bitcast <4 x i8> %1 to i32 - %mask8 = trunc <4 x i64> %2 to <4 x i8> - %mask32 = bitcast <4 x i8> %mask8 to i32 - %notmask32 = xor i32 %mask32, -1 - - %newmasked = and i32 %new32, %mask32 - %oldmasked = and i32 %old32, %notmask32 - %result = or i32 %newmasked, %oldmasked - - %resultvec = bitcast i32 %result to <4 x i8> - ',` - %m = trunc <4 x i64> %2 to <4 x i1> - %resultvec = select <4 x i1> %m, <4 x i8> %1, <4 x i8> %old - ') + %m = trunc <4 x i64> %2 to <4 x i1> + %resultvec = select <4 x i1> %m, <4 x i8> %1, <4 x i8> %old + store <4 x i8> %resultvec, <4 x i8> * %0, align 1 ret void } @@ -3996,23 +3957,10 @@ define void @__masked_store_blend_i8(<4 x i8>* nocapture, <4 x i8>, define void @__masked_store_blend_i16(<4 x i16>* nocapture, <4 x i16>, <4 x i64>) nounwind alwaysinline { %old = load <4 x i16> * %0, align 2 - ifelse(LLVM_VERSION,LLVM_3_0,` - %old64 = bitcast <4 x i16> %old to i64 - %new64 = bitcast <4 x i16> %1 to i64 - - %mask16 = trunc <4 x i64> %2 to <4 x i16> - %mask64 = bitcast <4 x i16> %mask16 to i64 - %notmask64 = xor i64 %mask64, -1 - - %newmasked = and i64 %new64, %mask64 - %oldmasked = and i64 %old64, %notmask64 - %result = or i64 %newmasked, %oldmasked - - %resultvec = bitcast i64 %result to <4 x i16> - ',` - %m = trunc <4 x i64> %2 to <4 x i1> - %resultvec = select <4 x i1> %m, <4 x i16> %1, <4 x i16> %old - ') + + %m = trunc <4 x i64> %2 to <4 x i1> + %resultvec = select <4 x i1> %m, <4 x i16> %1, <4 x i16> %old + store <4 x i16> %resultvec, <4 x i16> * %0, align 2 ret void } @@ -4022,23 +3970,10 @@ define(`masked_store_blend_8_16_by_8', ` define void @__masked_store_blend_i8(<8 x i8>* nocapture, <8 x i8>, <8 x i32>) nounwind alwaysinline { %old = load <8 x i8> * %0, align 1 - ifelse(LLVM_VERSION,LLVM_3_0,` - %old64 = bitcast <8 x i8> %old to i64 - %new64 = bitcast <8 x i8> %1 to i64 - - %mask8 = trunc <8 x i32> %2 to <8 x i8> - %mask64 = bitcast <8 x i8> %mask8 to i64 - %notmask64 = xor i64 %mask64, -1 - - %newmasked = and i64 %new64, %mask64 - %oldmasked = and i64 %old64, %notmask64 - %result = or i64 %newmasked, %oldmasked - - %resultvec = bitcast i64 %result to <8 x i8> - ',` - %m = trunc <8 x i32> %2 to <8 x i1> - %resultvec = select <8 x i1> %m, <8 x i8> %1, <8 x i8> %old - ') + + %m = trunc <8 x i32> %2 to <8 x i1> + %resultvec = select <8 x i1> %m, <8 x i8> %1, <8 x i8> %old + store <8 x i8> %resultvec, <8 x i8> * %0, align 1 ret void } @@ -4046,23 +3981,10 @@ define void @__masked_store_blend_i8(<8 x i8>* nocapture, <8 x i8>, define void @__masked_store_blend_i16(<8 x i16>* nocapture, <8 x i16>, <8 x i32>) nounwind alwaysinline { %old = load <8 x i16> * %0, align 2 - ifelse(LLVM_VERSION,LLVM_3_0,` - %old128 = bitcast <8 x i16> %old to i128 - %new128 = bitcast <8 x i16> %1 to i128 - - %mask16 = trunc <8 x i32> %2 to <8 x i16> - %mask128 = bitcast <8 x i16> %mask16 to i128 - %notmask128 = xor i128 %mask128, -1 - - %newmasked = and i128 %new128, %mask128 - %oldmasked = and i128 %old128, %notmask128 - %result = or i128 %newmasked, %oldmasked - - %resultvec = bitcast i128 %result to <8 x i16> - ',` - %m = trunc <8 x i32> %2 to <8 x i1> - %resultvec = select <8 x i1> %m, <8 x i16> %1, <8 x i16> %old - ') + + %m = trunc <8 x i32> %2 to <8 x i1> + %resultvec = select <8 x i1> %m, <8 x i16> %1, <8 x i16> %old + store <8 x i16> %resultvec, <8 x i16> * %0, align 2 ret void } @@ -4073,23 +3995,10 @@ define(`masked_store_blend_8_16_by_16', ` define void @__masked_store_blend_i8(<16 x i8>* nocapture, <16 x i8>, <16 x i32>) nounwind alwaysinline { %old = load <16 x i8> * %0, align 1 - ifelse(LLVM_VERSION,LLVM_3_0,` - %old128 = bitcast <16 x i8> %old to i128 - %new128 = bitcast <16 x i8> %1 to i128 - %mask8 = trunc <16 x i32> %2 to <16 x i8> - %mask128 = bitcast <16 x i8> %mask8 to i128 - %notmask128 = xor i128 %mask128, -1 + %m = trunc <16 x i32> %2 to <16 x i1> + %resultvec = select <16 x i1> %m, <16 x i8> %1, <16 x i8> %old - %newmasked = and i128 %new128, %mask128 - %oldmasked = and i128 %old128, %notmask128 - %result = or i128 %newmasked, %oldmasked - - %resultvec = bitcast i128 %result to <16 x i8> - ',` - %m = trunc <16 x i32> %2 to <16 x i1> - %resultvec = select <16 x i1> %m, <16 x i8> %1, <16 x i8> %old - ') store <16 x i8> %resultvec, <16 x i8> * %0, align 1 ret void } @@ -4097,23 +4006,10 @@ define void @__masked_store_blend_i8(<16 x i8>* nocapture, <16 x i8>, define void @__masked_store_blend_i16(<16 x i16>* nocapture, <16 x i16>, <16 x i32>) nounwind alwaysinline { %old = load <16 x i16> * %0, align 2 - ifelse(LLVM_VERSION,LLVM_3_0,` - %old256 = bitcast <16 x i16> %old to i256 - %new256 = bitcast <16 x i16> %1 to i256 - %mask16 = trunc <16 x i32> %2 to <16 x i16> - %mask256 = bitcast <16 x i16> %mask16 to i256 - %notmask256 = xor i256 %mask256, -1 + %m = trunc <16 x i32> %2 to <16 x i1> + %resultvec = select <16 x i1> %m, <16 x i16> %1, <16 x i16> %old - %newmasked = and i256 %new256, %mask256 - %oldmasked = and i256 %old256, %notmask256 - %result = or i256 %newmasked, %oldmasked - - %resultvec = bitcast i256 %result to <16 x i16> - ',` - %m = trunc <16 x i32> %2 to <16 x i1> - %resultvec = select <16 x i1> %m, <16 x i16> %1, <16 x i16> %old - ') store <16 x i16> %resultvec, <16 x i16> * %0, align 2 ret void } diff --git a/cbackend.cpp b/cbackend.cpp index aa7a9aca..9b9e61be 100644 --- a/cbackend.cpp +++ b/cbackend.cpp @@ -29,7 +29,7 @@ #include "llvmutil.h" -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/CallingConv.h" @@ -50,20 +50,18 @@ #endif #include "llvm/Pass.h" #include "llvm/PassManager.h" -#if !defined(LLVM_3_1) - #if defined(LLVM_3_2) - #include "llvm/TypeFinder.h" - #else // LLVM_3_3 + - #include "llvm/IR/TypeFinder.h" - #endif -#endif // LLVM_3_2 + +#if defined(LLVM_3_2) + #include "llvm/TypeFinder.h" +#else // LLVM_3_3 + + #include "llvm/IR/TypeFinder.h" +#endif #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Analysis/ConstantsScanner.h" #include "llvm/Analysis/FindUsedTypes.h" #include "llvm/Analysis/LoopInfo.h" -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) #include "llvm/IR/Verifier.h" #include #include "llvm/IR/CallSite.h" @@ -96,7 +94,7 @@ #endif #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include "llvm/Support/InstVisitor.h" #elif defined (LLVM_3_3) || defined (LLVM_3_4) #include "llvm/InstVisitor.h" @@ -250,7 +248,8 @@ namespace { class CBEMCAsmInfo : public llvm::MCAsmInfo { public: CBEMCAsmInfo() { -#if !defined(LLVM_3_5) && !defined(LLVM_3_6) + +#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) GlobalPrefix = ""; #endif PrivateGlobalPrefix = ""; @@ -269,14 +268,11 @@ namespace { const llvm::MCRegisterInfo *MRI; const llvm::MCObjectFileInfo *MOFI; llvm::MCContext *TCtx; -#if defined(LLVM_3_1) - const llvm::TargetData* TD; -#else + // FIXME: it's ugly to have the name be "TD" here, but it saves us // lots of ifdefs in the below since the new DataLayout and the old // TargetData have generally similar interfaces... const llvm::DataLayout* TD; -#endif std::map FPConstantMap; std::map VectorConstantMap; @@ -363,7 +359,7 @@ namespace { bool isSigned = false, const std::string &VariableName = "", bool IgnoreName = false, -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) const llvm::AttrListPtr &PAL = llvm::AttrListPtr() #else const llvm::AttributeSet &PAL = llvm::AttributeSet() @@ -374,7 +370,7 @@ namespace { const std::string &NameSoFar = ""); void printStructReturnPointerFunctionType(llvm::raw_ostream &Out, -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) const llvm::AttrListPtr &PAL, #else const llvm::AttributeSet &PAL, @@ -465,7 +461,8 @@ namespace { // Must not be used in inline asm, extractelement, or shufflevector. if (I.hasOneUse()) { -#if defined(LLVM_3_5) || defined(LLVM_3_6) + +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) const llvm::Instruction &User = llvm::cast(*I.user_back()); #else const llvm::Instruction &User = llvm::cast(*I.use_back()); @@ -477,7 +474,7 @@ namespace { } // Only inline instruction it if it's use is in the same BB as the inst. -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) return I.getParent() == llvm::cast(I.user_back())->getParent(); #else return I.getParent() == llvm::cast(I.use_back())->getParent(); @@ -613,7 +610,7 @@ std::string CWriter::getArrayName(llvm::ArrayType *AT) { /// return type, except, instead of printing the type as void (*)(Struct*, ...) /// print it as "Struct (*)(...)", for struct return functions. void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out, -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) const llvm::AttrListPtr &PAL, #else const llvm::AttributeSet &PAL, @@ -632,9 +629,7 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out, if (PrintedType) FunctionInnards << ", "; llvm::Type *ArgTy = *I; -#if defined(LLVM_3_1) - if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) { -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) { #else if (PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::ByVal)) { @@ -643,9 +638,7 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out, ArgTy = llvm::cast(ArgTy)->getElementType(); } printType(FunctionInnards, ArgTy, -#if defined(LLVM_3_1) - /*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt), -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt), #else PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt), @@ -662,9 +655,7 @@ void CWriter::printStructReturnPointerFunctionType(llvm::raw_ostream &Out, } FunctionInnards << ')'; printType(Out, RetTy, -#if defined(LLVM_3_1) - /*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt), -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt), #else PAL.getParamAttributes(0).hasAttribute(llvm::AttributeSet::ReturnIndex, llvm::Attribute::SExt), @@ -764,7 +755,7 @@ CWriter::printSimpleType(llvm::raw_ostream &Out, llvm::Type *Ty, bool isSigned, llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty, bool isSigned, const std::string &NameSoFar, bool IgnoreName, -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) const llvm::AttrListPtr &PAL #else const llvm::AttributeSet &PAL @@ -786,9 +777,7 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty, for (llvm::FunctionType::param_iterator I = FTy->param_begin(), E = FTy->param_end(); I != E; ++I) { llvm::Type *ArgTy = *I; -#if defined(LLVM_3_1) - if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) { -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) { #else if (PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::ByVal)) { @@ -799,9 +788,7 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty, if (I != FTy->param_begin()) FunctionInnards << ", "; printType(FunctionInnards, ArgTy, -#if defined(LLVM_3_1) - /*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt), -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt), #else PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt), @@ -818,9 +805,7 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty, } FunctionInnards << ')'; printType(Out, FTy->getReturnType(), -#if defined(LLVM_3_1) - /*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt), -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt), #else PAL.getParamAttributes(0).hasAttribute(llvm::AttributeSet::ReturnIndex, llvm::Attribute::SExt), @@ -1770,7 +1755,7 @@ std::string CWriter::GetValueName(const llvm::Value *Operand) { // Resolve potential alias. if (const llvm::GlobalAlias *GA = llvm::dyn_cast(Operand)) { -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) if (const llvm::Value *V = GA->getAliasee()) #else if (const llvm::Value *V = GA->resolveAliasedGlobal(false)) @@ -2003,11 +1988,7 @@ void CWriter::writeOperandWithCast(llvm::Value* Operand, const llvm::ICmpInst &C // directives to cater to specific compilers as need be. // static void generateCompilerSpecificCode(llvm::formatted_raw_ostream& Out, -#if defined(LLVM_3_1) - const llvm::TargetData *TD) { -#else const llvm::DataLayout *TD) { -#endif // We output GCC specific attributes to preserve 'linkonce'ness on globals. // If we aren't being compiled with GCC, just drop these attributes. Out << "#ifndef __GNUC__ /* Can only support \"linkonce\" vars with GCC */\n" @@ -2163,7 +2144,7 @@ static SpecialGlobalClass getGlobalVariableClass(const llvm::GlobalVariable *GV) // Otherwise, if it is other metadata, don't print it. This catches things // like debug information. -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // Here we compare char * if (!strcmp(GV->getSection(), "llvm.metadata")) #else @@ -2206,11 +2187,7 @@ bool CWriter::doInitialization(llvm::Module &M) { // Initialize TheModule = &M; -#if defined(LLVM_3_1) - TD = new llvm::TargetData(&M); -#else TD = new llvm::DataLayout(&M); -#endif IL = new llvm::IntrinsicLowering(*TD); IL->AddPrototypes(M); @@ -2225,7 +2202,7 @@ bool CWriter::doInitialization(llvm::Module &M) { #endif TAsm = new CBEMCAsmInfo(); MRI = new llvm::MCRegisterInfo(); -#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) TCtx = new llvm::MCContext(TAsm, MRI, NULL); #else TCtx = new llvm::MCContext(*TAsm, *MRI, NULL); @@ -2349,7 +2326,7 @@ bool CWriter::doInitialization(llvm::Module &M) { if (I->hasExternalLinkage() || I->hasExternalWeakLinkage() || I->hasCommonLinkage()) Out << "extern "; -#if defined (LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) else if (I->hasDLLImportStorageClass()) #else else if (I->hasDLLImportLinkage()) @@ -2525,7 +2502,7 @@ bool CWriter::doInitialization(llvm::Module &M) { if (I->hasLocalLinkage()) Out << "static "; -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) else if (I->hasDLLImportStorageClass()) Out << "__declspec(dllimport) "; else if (I->hasDLLExportStorageClass()) Out << "__declspec(dllexport) "; #else @@ -2699,15 +2676,11 @@ void CWriter::printModuleTypes() { // Get all of the struct types used in the module. std::vector StructTypes; -#if defined(LLVM_3_1) - TheModule->findUsedStructTypes(StructTypes); -#else llvm::TypeFinder typeFinder; typeFinder.run(*TheModule, false); for (llvm::TypeFinder::iterator iter = typeFinder.begin(); iter != typeFinder.end(); ++iter) StructTypes.push_back(*iter); -#endif // Get all of the array types used in the module std::vector ArrayTypes; @@ -2810,7 +2783,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) { bool isStructReturn = F->hasStructRetAttr(); if (F->hasLocalLinkage()) Out << "static "; -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ if (F->hasDLLImportStorageClass()) Out << "__declspec(dllimport) "; if (F->hasDLLExportStorageClass()) Out << "__declspec(dllexport) "; #else @@ -2833,7 +2806,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) { // Loop over the arguments, printing them... llvm::FunctionType *FT = llvm::cast(F->getFunctionType()); -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) const llvm::AttrListPtr &PAL = F->getAttributes(); #else const llvm::AttributeSet &PAL = F->getAttributes(); @@ -2867,9 +2840,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) { else ArgName = ""; llvm::Type *ArgTy = I->getType(); -#if defined(LLVM_3_1) - if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) { -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) { #else if (PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::ByVal)) { @@ -2878,9 +2849,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) { ByValParams.insert(I); } printType(FunctionInnards, ArgTy, -#if defined(LLVM_3_1) - /*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt), -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt), #else PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt), @@ -2906,9 +2875,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) { for (; I != E; ++I) { if (PrintedArg) FunctionInnards << ", "; llvm::Type *ArgTy = *I; -#if defined(LLVM_3_1) - if (PAL.paramHasAttr(Idx, llvm::Attribute::ByVal)) { -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) if (PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::ByVal)) { #else if (PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::ByVal)) { @@ -2917,9 +2884,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) { ArgTy = llvm::cast(ArgTy)->getElementType(); } printType(FunctionInnards, ArgTy, -#if defined(LLVM_3_1) - /*isSigned=*/PAL.paramHasAttr(Idx, llvm::Attribute::SExt) -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) PAL.getParamAttributes(Idx).hasAttribute(llvm::Attributes::SExt) #else PAL.getParamAttributes(Idx).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt) @@ -2956,9 +2921,7 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) { // Print out the return type and the signature built above. printType(Out, RetTy, -#if defined(LLVM_3_1) - /*isSigned=*/PAL.paramHasAttr(0, llvm::Attribute::SExt), -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) PAL.getParamAttributes(0).hasAttribute(llvm::Attributes::SExt), #else PAL.getParamAttributes(0).hasAttribute(llvm::AttributeSet::ReturnIndex, llvm::Attribute::SExt), @@ -3145,7 +3108,8 @@ void CWriter::visitSwitchInst(llvm::SwitchInst &SI) { Out << ":\n"; printPHICopiesForSuccessor (SI.getParent(), Succ, 2); printBranchToBlock(SI.getParent(), Succ, 2); -#if defined (LLVM_3_5) || defined(LLVM_3_6) + +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ if (llvm::Function::iterator(Succ) == std::next(llvm::Function::iterator(SI.getParent()))) #else if (llvm::Function::iterator(Succ) == llvm::next(llvm::Function::iterator(SI.getParent()))) @@ -3170,7 +3134,7 @@ bool CWriter::isGotoCodeNecessary(llvm::BasicBlock *From, llvm::BasicBlock *To) /// FIXME: This should be reenabled, but loop reordering safe!! return true; -#if defined (LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ if (std::next(llvm::Function::iterator(From)) != llvm::Function::iterator(To)) #else if (llvm::next(llvm::Function::iterator(From)) != llvm::Function::iterator(To)) @@ -3775,7 +3739,7 @@ void CWriter::lowerIntrinsics(llvm::Function &F) { const char *BuiltinName = ""; #define GET_GCC_BUILTIN_NAME #define Intrinsic llvm::Intrinsic -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include "llvm/Intrinsics.gen" #else #include "llvm/IR/Intrinsics.gen" @@ -3788,7 +3752,7 @@ void CWriter::lowerIntrinsics(llvm::Function &F) { // All other intrinsic calls we must lower. llvm::Instruction *Before = 0; if (CI != &BB->front()) -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) Before = std::prev(llvm::BasicBlock::iterator(CI)); #else Before = prior(llvm::BasicBlock::iterator(CI)); @@ -3844,7 +3808,7 @@ void CWriter::visitCallInst(llvm::CallInst &I) { // If this is a call to a struct-return function, assign to the first // parameter instead of passing it to the call. -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) const llvm::AttrListPtr &PAL = I.getAttributes(); #else const llvm::AttributeSet &PAL = I.getAttributes(); @@ -3932,9 +3896,7 @@ void CWriter::visitCallInst(llvm::CallInst &I) { (*AI)->getType() != FTy->getParamType(ArgNo)) { Out << '('; printType(Out, FTy->getParamType(ArgNo), -#if defined(LLVM_3_1) - /*isSigned=*/PAL.paramHasAttr(ArgNo+1, llvm::Attribute::SExt) -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::Attributes::SExt) #else PAL.getParamAttributes(ArgNo+1).hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::SExt) @@ -3972,7 +3934,7 @@ bool CWriter::visitBuiltinCall(llvm::CallInst &I, llvm::Intrinsic::ID ID, const char *BuiltinName = ""; #define GET_GCC_BUILTIN_NAME #define Intrinsic llvm::Intrinsic -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include "llvm/Intrinsics.gen" #else #include "llvm/IR/Intrinsics.gen" @@ -4625,13 +4587,8 @@ SmearCleanupPass::runOnBasicBlock(llvm::BasicBlock &bb) { smearType, NULL); smearFunc = llvm::dyn_cast(sf); assert(smearFunc != NULL); -#if defined(LLVM_3_1) - smearFunc->setDoesNotThrow(true); - smearFunc->setDoesNotAccessMemory(true); -#else smearFunc->setDoesNotThrow(); smearFunc->setDoesNotAccessMemory(); -#endif } assert(smearFunc != NULL); @@ -4773,13 +4730,8 @@ AndCmpCleanupPass::runOnBasicBlock(llvm::BasicBlock &bb) { LLVMTypes::MaskType, NULL); andCmpFunc = llvm::dyn_cast(acf); Assert(andCmpFunc != NULL); -#if defined(LLVM_3_1) - andCmpFunc->setDoesNotThrow(true); - andCmpFunc->setDoesNotAccessMemory(true); -#else andCmpFunc->setDoesNotThrow(); andCmpFunc->setDoesNotAccessMemory(); -#endif } // Set up the function call to the *_and_mask function; the @@ -4984,7 +4936,7 @@ WriteCXXFile(llvm::Module *module, const char *fn, int vectorWidth, pm.add(new llvm::TargetData(module)); #endif -#if defined(LLVM_3_1) || defined(LLVM_3_2) || defined(LLVM_3_3) +#if defined(LLVM_3_2) || defined(LLVM_3_3) int flags = 0; #else llvm::sys::fs::OpenFlags flags = llvm::sys::fs::F_None; @@ -5009,7 +4961,7 @@ WriteCXXFile(llvm::Module *module, const char *fn, int vectorWidth, pm.add(llvm::createDeadCodeEliminationPass()); // clean up after smear pass //CO pm.add(llvm::createPrintModulePass(&fos)); pm.add(new CWriter(fos, includeName, vectorWidth)); -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) // This interface is depricated for 3.3+ pm.add(llvm::createGCInfoDeleter()); #endif diff --git a/ctx.cpp b/ctx.cpp index 8026c10a..b6d0d2c5 100644 --- a/ctx.cpp +++ b/ctx.cpp @@ -46,7 +46,7 @@ #include "sym.h" #include #include -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #include @@ -336,7 +336,7 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym, diFile = funcStartPos.GetDIFile(); AssertPos(currentPos, diFile.Verify()); -#if defined(LLVM_3_1) || defined(LLVM_3_2) || defined(LLVM_3_3) +#if defined(LLVM_3_2) || defined(LLVM_3_3) llvm::DIScope scope = llvm::DIScope(m->diBuilder->getCU()); #else // LLVM_3_4+ llvm::DIScope scope = llvm::DIScope(m->diCompileUnit); @@ -352,7 +352,7 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym, AssertPos(currentPos, diSubprogramType.Verify()); } -#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) Assert(diSubprogramType.isCompositeType()); llvm::DICompositeType diSubprogramType_n = static_cast(diSubprogramType); @@ -3339,7 +3339,7 @@ FunctionEmitContext::CallInst(llvm::Value *func, const FunctionType *funcType, // alias analysis. // TODO: what other attributes needs to be copied? // TODO: do the same for varing path. -#if !defined (LLVM_3_1) && !defined (LLVM_3_2) // LLVM 3.3+ +#if !defined (LLVM_3_2) // LLVM 3.3+ llvm::CallInst *cc = llvm::dyn_cast(ci); if (cc && cc->getCalledFunction() && diff --git a/ctx.h b/ctx.h index 3b9ce86a..288b9af3 100644 --- a/ctx.h +++ b/ctx.h @@ -40,7 +40,7 @@ #include "ispc.h" #include -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #else diff --git a/expr.cpp b/expr.cpp index aeb8b670..8a82a1f8 100644 --- a/expr.cpp +++ b/expr.cpp @@ -56,7 +56,7 @@ #include #include #include -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #include @@ -3184,14 +3184,7 @@ static llvm::Value * lEmitVaryingSelect(FunctionEmitContext *ctx, llvm::Value *test, llvm::Value *expr1, llvm::Value *expr2, const Type *type) { -#if 0 // !defined(LLVM_3_1) - // Though it should be equivalent, this seems to cause non-trivial - // performance regressions versus the below. This may be related to - // http://llvm.org/bugs/show_bug.cgi?id=16941. - if (test->getType() != LLVMTypes::Int1VectorType) - test = ctx->TruncInst(test, LLVMTypes::Int1VectorType); - return ctx->SelectInst(test, expr1, expr2, "select"); -#else + llvm::Value *resultPtr = ctx->AllocaInst(expr1->getType(), "selectexpr_tmp"); // Don't need to worry about masking here ctx->StoreInst(expr2, resultPtr); @@ -3200,7 +3193,6 @@ lEmitVaryingSelect(FunctionEmitContext *ctx, llvm::Value *test, PointerType::GetUniform(type)->LLVMType(g->ctx)); ctx->StoreInst(expr1, resultPtr, test, type, PointerType::GetUniform(type)); return ctx->LoadInst(resultPtr, "selectexpr_final"); -#endif // !LLVM_3_1 } diff --git a/func.cpp b/func.cpp index 1c92d112..fb3a75b2 100644 --- a/func.cpp +++ b/func.cpp @@ -46,7 +46,7 @@ #include "util.h" #include -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #include @@ -355,9 +355,7 @@ Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function, // isn't worth the code bloat / overhead. bool checkMask = (type->isTask == true) || ( -#if defined(LLVM_3_1) - (function->hasFnAttr(llvm::Attribute::AlwaysInline) == false) -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) (function->getFnAttributes().hasAttribute(llvm::Attributes::AlwaysInline) == false) #else // LLVM 3.3+ (function->getAttributes().getFnAttributes().hasAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::AlwaysInline) == false) @@ -502,11 +500,8 @@ Function::GenerateIR() { functionName += std::string("_") + g->target->GetISAString(); llvm::Function *appFunction = llvm::Function::Create(ftype, linkage, functionName.c_str(), m->module); -#if defined(LLVM_3_1) - appFunction->setDoesNotThrow(true); -#else appFunction->setDoesNotThrow(); -#endif + // We should iterate from 1 because zero parameter is return. // We should iterate till getNumParams instead of getNumParams+1 because new // function is export function and doesn't contain the last parameter "mask". diff --git a/ispc.cpp b/ispc.cpp index 913a2d99..593b1452 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -48,7 +48,7 @@ #include #include #endif -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #include @@ -67,9 +67,7 @@ #include #include #include -#if defined(LLVM_3_1) - #include -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #else // LLVM 3.3+ #include @@ -165,10 +163,8 @@ static const char *supportedCPUs[] = { "cortex-a9", "cortex-a15", #endif "atom", "penryn", "core2", "corei7", "corei7-avx" -#if !defined(LLVM_3_1) , "core-avx-i", "core-avx2" -#endif // LLVM 3.2+ -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) && !defined(LLVM_3_3) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) , "slm" #endif // LLVM 3.4+ }; @@ -176,18 +172,14 @@ static const char *supportedCPUs[] = { Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) : m_target(NULL), m_targetMachine(NULL), -#if defined(LLVM_3_1) - m_targetData(NULL), -#else m_dataLayout(NULL), -#endif m_valid(false), m_isa(SSE2), m_arch(""), m_is32Bit(true), m_cpu(""), m_attributes(""), -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) +#if !defined(LLVM_3_2) m_tf_attributes(NULL), #endif m_nativeVectorWidth(-1), @@ -644,10 +636,8 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) : m_isa == Target::NEON32) options.FloatABIType = llvm::FloatABI::Hard; #endif -#if !defined(LLVM_3_1) if (g->opt.disableFMA == false) options.AllowFPOpFusion = llvm::FPOpFusion::Fast; -#endif // !LLVM_3_1 #ifdef ISPC_IS_WINDOWS if (strcmp("x86", arch) == 0) { @@ -666,11 +656,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) : // Initialize TargetData/DataLayout in 3 steps. // 1. Get default data layout first std::string dl_string; -#if defined(LLVM_3_1) - dl_string = m_targetMachine->getTargetData()->getStringRepresentation(); -#else dl_string = m_targetMachine->getDataLayout()->getStringRepresentation(); -#endif // 2. Adjust for generic if (m_isa == Target::GENERIC) { @@ -685,11 +671,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) : } // 3. Finally set member data -#if defined(LLVM_3_1) - m_targetData = new llvm::TargetData(dl_string); -#else m_dataLayout = new llvm::DataLayout(dl_string); -#endif // Set is32Bit // This indicates if we are compiling for 32 bit platform @@ -697,7 +679,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) : // FIXME: all generic targets are handled as 64 bit, which is incorrect. this->m_is32Bit = (getDataLayout()->getPointerSize() == 4); -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) +#if !defined(LLVM_3_2) // This is LLVM 3.3+ feature. // Initialize target-specific "target-feature" attribute. if (!m_attributes.empty()) { @@ -973,7 +955,7 @@ Target::StructOffset(llvm::Type *type, int element, } void Target::markFuncWithTargetAttr(llvm::Function* func) { -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) +#if !defined(LLVM_3_2) if (m_tf_attributes) { func->addAttributes(llvm::AttributeSet::FunctionIndex, *m_tf_attributes); } diff --git a/ispc.h b/ispc.h index 29925e46..2050ac44 100644 --- a/ispc.h +++ b/ispc.h @@ -40,8 +40,8 @@ #define ISPC_VERSION "1.7.1dev" -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) && !defined(LLVM_3_6) -#error "Only LLVM 3.1, 3.2, 3.3, 3.4, 3.5 and the 3.6 development branch are supported" +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) && !defined(LLVM_3_6) +#error "Only LLVM 3.2, 3.3, 3.4, 3.5 and the 3.6 development branch are supported" #endif #if defined(_WIN32) || defined(_WIN64) @@ -76,11 +76,7 @@ namespace llvm { class BasicBlock; class Constant; class ConstantValue; -#if defined(LLVM_3_1) - class TargetData; -#else class DataLayout; -#endif class DIBuilder; class DIDescriptor; class DIFile; @@ -241,11 +237,7 @@ public: // Note the same name of method for 3.1 and 3.2+, this allows // to reduce number ifdefs on client side. -#if defined(LLVM_3_1) - llvm::TargetData *getDataLayout() const {return m_targetData;} -#else llvm::DataLayout *getDataLayout() const {return m_dataLayout;} -#endif /** Reports if Target object has valid state. */ bool isValid() const {return m_valid;} @@ -302,12 +294,7 @@ private: must not be used. */ llvm::TargetMachine *m_targetMachine; - -#if defined(LLVM_3_1) - llvm::TargetData *m_targetData; -#else llvm::DataLayout *m_dataLayout; -#endif /** flag to report invalid state after construction (due to bad parameters passed to constructor). */ @@ -328,7 +315,7 @@ private: /** Target-specific attribute string to pass along to the LLVM backend */ std::string m_attributes; -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) +#if !defined(LLVM_3_2) /** Target-specific LLVM attribute, which has to be attached to every function to ensure that it is generated for correct target architecture. This is requirement was introduced in LLVM 3.3 */ diff --git a/ispc.vcxproj b/ispc.vcxproj index 2ce69fde..4308715a 100755 --- a/ispc.vcxproj +++ b/ispc.vcxproj @@ -403,7 +403,7 @@ true $(LLVM_INSTALL_DIR)\lib;%(AdditionalLibraryDirectories) clangFrontend.lib;clangDriver.lib;clangSerialization.lib;clangParse.lib;clangSema.lib;clangAnalysis.lib;clangEdit.lib;clangAST.lib;clangLex.lib;clangBasic.lib;LLVMAnalysis.lib;LLVMAsmParser.lib;LLVMAsmPrinter.lib;LLVMBitReader.lib;LLVMBitWriter.lib;LLVMCodeGen.lib;LLVMCore.lib;LLVMExecutionEngine.lib;LLVMInstCombine.lib;LLVMInstrumentation.lib;LLVMLinker.lib;LLVMMC.lib;LLVMMCParser.lib;LLVMObject.lib;LLVMScalarOpts.lib;LLVMSelectionDAG.lib;LLVMSupport.lib;LLVMTarget.lib;LLVMTransformUtils.lib;LLVMX86ASMPrinter.lib;LLVMX86ASMParser.lib;LLVMX86Utils.lib;LLVMX86CodeGen.lib;LLVMX86Desc.lib;LLVMX86Disassembler.lib;LLVMX86Info.lib;LLVMipa.lib;LLVMipo.lib;shlwapi.lib;%(AdditionalDependencies) - LLVMOption.lib;LLVMSupport.lib;%(AdditionalDependencies) + LLVMOption.lib;LLVMSupport.lib;%(AdditionalDependencies) @@ -424,7 +424,7 @@ true $(LLVM_INSTALL_DIR)\lib;%(AdditionalLibraryDirectories) clangFrontend.lib;clangDriver.lib;clangSerialization.lib;clangParse.lib;clangSema.lib;clangAnalysis.lib;clangEdit.lib;clangAST.lib;clangLex.lib;clangBasic.lib;LLVMAnalysis.lib;LLVMAsmParser.lib;LLVMAsmPrinter.lib;LLVMBitReader.lib;LLVMBitWriter.lib;LLVMCodeGen.lib;LLVMCore.lib;LLVMExecutionEngine.lib;LLVMInstCombine.lib;LLVMInstrumentation.lib;LLVMLinker.lib;LLVMMC.lib;LLVMMCParser.lib;LLVMObject.lib;LLVMScalarOpts.lib;LLVMSelectionDAG.lib;LLVMSupport.lib;LLVMTarget.lib;LLVMTransformUtils.lib;LLVMX86ASMPrinter.lib;LLVMX86ASMParser.lib;LLVMX86Utils.lib;LLVMX86CodeGen.lib;LLVMX86Desc.lib;LLVMX86Disassembler.lib;LLVMX86Info.lib;LLVMipa.lib;LLVMipo.lib;shlwapi.lib;%(AdditionalDependencies) - LLVMOption.lib;LLVMSupport.lib;%(AdditionalDependencies) + LLVMOption.lib;LLVMSupport.lib;%(AdditionalDependencies) diff --git a/llvmutil.cpp b/llvmutil.cpp index c9e156ce..3ec5ebef 100644 --- a/llvmutil.cpp +++ b/llvmutil.cpp @@ -38,7 +38,7 @@ #include "llvmutil.h" #include "ispc.h" #include "type.h" -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #else diff --git a/llvmutil.h b/llvmutil.h index 96310b94..cb4cd27e 100644 --- a/llvmutil.h +++ b/llvmutil.h @@ -38,7 +38,7 @@ #ifndef ISPC_LLVMUTIL_H #define ISPC_LLVMUTIL_H 1 -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #include diff --git a/main.cpp b/main.cpp index 97dec095..256b5f4a 100644 --- a/main.cpp +++ b/main.cpp @@ -62,9 +62,7 @@ static void lPrintVersion() { printf("Intel(r) SPMD Program Compiler (ispc), %s (build %s @ %s, LLVM %s)\n", ISPC_VERSION, BUILD_VERSION, BUILD_DATE, -#if defined(LLVM_3_1) - "3.1" -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) "3.2" #elif defined(LLVM_3_3) "3.3" diff --git a/module.cpp b/module.cpp index ce7e6bde..e76c0c7c 100644 --- a/module.cpp +++ b/module.cpp @@ -64,7 +64,7 @@ #define strcasecmp stricmp #endif -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #include @@ -206,7 +206,7 @@ lStripUnusedDebugInfo(llvm::Module *module) { // stuff and remove it later on. Removing it is useful, as it // reduces size of the binary significantly (manyfold for small // programs). -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) llvm::MDNode *nodeSPMD = llvm::dyn_cast(cuNode->getOperand(12)); Assert(nodeSPMD != NULL); @@ -311,7 +311,7 @@ Module::Module(const char *fn) { sprintf(producerString, "ispc version %s (built on %s)", ISPC_VERSION, __DATE__); #endif -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) && !defined(LLVM_3_3) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) diCompileUnit = #endif // LLVM_3_4+ diBuilder->createCompileUnit(llvm::dwarf::DW_LANG_C99, /* lang */ @@ -796,16 +796,12 @@ Module::AddFunctionDeclaration(const std::string &name, isInline) #ifdef LLVM_3_2 function->addFnAttr(llvm::Attributes::AlwaysInline); -#else // LLVM 3.1 and 3.3+ +#else // LLVM 3.3+ function->addFnAttr(llvm::Attribute::AlwaysInline); #endif if (functionType->isTask) // This also applies transitively to members I think? -#if defined(LLVM_3_1) - function->setDoesNotAlias(1, true); -#else // LLVM 3.2+ function->setDoesNotAlias(1); -#endif g->target->markFuncWithTargetAttr(function); @@ -856,12 +852,7 @@ Module::AddFunctionDeclaration(const std::string &name, // NOTE: LLVM indexes function parameters starting from 1. // This is unintuitive. -#if defined(LLVM_3_1) - function->setDoesNotAlias(i+1, true); -#else function->setDoesNotAlias(i+1); -#endif - #if 0 int align = 4 * RoundUpPow2(g->target->nativeVectorWidth); function->addAttribute(i+1, llvm::Attribute::constructAlignmentFromInt(align)); @@ -1086,7 +1077,7 @@ Module::writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine, llvm::TargetMachine::CodeGenFileType fileType = (outputType == Object) ? llvm::TargetMachine::CGFT_ObjectFile : llvm::TargetMachine::CGFT_AssemblyFile; bool binary = (fileType == llvm::TargetMachine::CGFT_ObjectFile); -#if defined(LLVM_3_1) || defined(LLVM_3_2) || defined(LLVM_3_3) +#if defined(LLVM_3_2) || defined(LLVM_3_3) unsigned int flags = binary ? llvm::raw_fd_ostream::F_Binary : 0; #elif defined(LLVM_3_4) llvm::sys::fs::OpenFlags flags = binary ? llvm::sys::fs::F_Binary : @@ -1986,25 +1977,17 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre llvm::raw_fd_ostream stderrRaw(2, false); -#if defined(LLVM_3_1) - clang::TextDiagnosticPrinter *diagPrinter = - new clang::TextDiagnosticPrinter(stderrRaw, clang::DiagnosticOptions()); -#else clang::DiagnosticOptions *diagOptions = new clang::DiagnosticOptions(); clang::TextDiagnosticPrinter *diagPrinter = new clang::TextDiagnosticPrinter(stderrRaw, diagOptions); -#endif + llvm::IntrusiveRefCntPtr diagIDs(new clang::DiagnosticIDs); -#if defined(LLVM_3_1) - clang::DiagnosticsEngine *diagEngine = - new clang::DiagnosticsEngine(diagIDs, diagPrinter); -#else clang::DiagnosticsEngine *diagEngine = new clang::DiagnosticsEngine(diagIDs, diagOptions, diagPrinter); -#endif + inst.setDiagnostics(diagEngine); -#if defined(LLVM_3_1) || defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) +#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) clang::TargetOptions &options = inst.getTargetOpts(); #else // LLVM 3.5+ const std::shared_ptr< clang::TargetOptions > &options = @@ -2016,13 +1999,13 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre triple.setTriple(llvm::sys::getDefaultTargetTriple()); } -#if defined(LLVM_3_1) || defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) +#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) options.Triple = triple.getTriple(); #else // LLVM 3.5+ options->Triple = triple.getTriple(); #endif -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) clang::TargetInfo *target = clang::TargetInfo::CreateTargetInfo(inst.getDiagnostics(), options); #elif defined(LLVM_3_3) || defined(LLVM_3_4) @@ -2035,18 +2018,14 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre inst.setTarget(target); inst.createSourceManager(inst.getFileManager()); -#if defined(LLVM_3_1) - inst.InitializeSourceManager(infilename); -#else clang::FrontendInputFile inputFile(infilename, clang::IK_None); inst.InitializeSourceManager(inputFile); -#endif // Don't remove comments in the preprocessor, so that we can accurately // track the source file position by handling them ourselves. inst.getPreprocessorOutputOpts().ShowComments = 1; -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) // LLVM 3.3+ +#if !defined(LLVM_3_2) // LLVM 3.3+ inst.getPreprocessorOutputOpts().ShowCPP = 1; #endif @@ -2058,7 +2037,7 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre headerOpts.Verbose = 1; for (int i = 0; i < (int)g->includePath.size(); ++i) { headerOpts.AddPath(g->includePath[i], clang::frontend::Angled, -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) true /* is user supplied */, #endif false /* not a framework */, diff --git a/module.h b/module.h index 7575457f..04bc3e52 100644 --- a/module.h +++ b/module.h @@ -161,7 +161,7 @@ public: /** The diBuilder manages generating debugging information */ llvm::DIBuilder *diBuilder; -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) && !defined(LLVM_3_3) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) llvm::DICompileUnit diCompileUnit; #endif // LLVM_3_4+ diff --git a/opt.cpp b/opt.cpp index a42a2268..8e0b2c7e 100644 --- a/opt.cpp +++ b/opt.cpp @@ -48,7 +48,7 @@ #include #include -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #include @@ -583,7 +583,7 @@ Optimize(llvm::Module *module, int optLevel) { optPM.add(llvm::createCFGSimplificationPass()); optPM.add(llvm::createArgumentPromotionPass()); -#if defined(LLVM_3_1) || defined(LLVM_3_2) || defined(LLVM_3_3) +#if defined(LLVM_3_2) || defined(LLVM_3_3) // Starting from 3.4 this functionality was moved to // InstructionCombiningPass. See r184459 for details. optPM.add(llvm::createSimplifyLibCallsPass(), 240); @@ -4654,7 +4654,7 @@ PeepholePass::PeepholePass() : BasicBlockPass(ID) { } -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) +#if !defined(LLVM_3_2) using namespace llvm::PatternMatch; @@ -4975,7 +4975,7 @@ lMatchAvgDownInt16(llvm::Value *inst) { } return NULL; } -#endif // !LLVM_3_1 && !LLVM_3_2 +#endif // !LLVM_3_2 bool @@ -4988,7 +4988,7 @@ PeepholePass::runOnBasicBlock(llvm::BasicBlock &bb) { llvm::Instruction *inst = &*iter; llvm::Instruction *builtinCall = NULL; -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) +#if !defined(LLVM_3_2) if (!builtinCall) builtinCall = lMatchAvgUpUInt8(inst); if (!builtinCall) @@ -5005,7 +5005,7 @@ PeepholePass::runOnBasicBlock(llvm::BasicBlock &bb) { builtinCall = lMatchAvgDownInt8(inst); if (!builtinCall) builtinCall = lMatchAvgDownInt16(inst); -#endif // !LLVM_3_1 && !LLVM_3_2 +#endif // !LLVM_3_2 if (builtinCall != NULL) { llvm::ReplaceInstWithInst(inst, builtinCall); modifiedAny = true; diff --git a/parse.yy b/parse.yy index 39693b70..daa41e54 100644 --- a/parse.yy +++ b/parse.yy @@ -83,7 +83,7 @@ struct ForeachDimension; #include "util.h" #include -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #else #include diff --git a/stmt.cpp b/stmt.cpp index 14c4146b..b741b61e 100644 --- a/stmt.cpp +++ b/stmt.cpp @@ -48,7 +48,7 @@ #include #include -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #include diff --git a/type.cpp b/type.cpp index 9579ebba..eaa85dba 100644 --- a/type.cpp +++ b/type.cpp @@ -43,7 +43,7 @@ #include #include -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #else @@ -830,9 +830,7 @@ EnumType::GetDIType(llvm::DIDescriptor scope) const { 32 /* size in bits */, 32 /* align in bits */, elementArray -#if !defined(LLVM_3_1) , llvm::DIType() -#endif ); @@ -2205,7 +2203,7 @@ StructType::GetDIType(llvm::DIDescriptor scope) const { currentSize, // Size in bits align, // Alignment in bits 0, // Flags -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) +#if !defined(LLVM_3_2) llvm::DIType(), // DerivedFrom #endif elements); @@ -2448,7 +2446,7 @@ UndefinedStructType::GetDIType(llvm::DIDescriptor scope) const { 0, // Size 0, // Align 0, // Flags -#if !defined(LLVM_3_1) && !defined(LLVM_3_2) +#if !defined(LLVM_3_2) llvm::DIType(), // DerivedFrom #endif elements); @@ -2711,12 +2709,8 @@ ReferenceType::GetDIType(llvm::DIDescriptor scope) const { } llvm::DIType diTargetType = targetType->GetDIType(scope); -#if defined(LLVM_3_1) - return m->diBuilder->createReferenceType(diTargetType); -#else return m->diBuilder->createReferenceType(llvm::dwarf::DW_TAG_reference_type, diTargetType); -#endif } diff --git a/type.h b/type.h index 94648eb1..708c7165 100644 --- a/type.h +++ b/type.h @@ -40,7 +40,7 @@ #include "ispc.h" #include "util.h" -#if defined(LLVM_3_1) || defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #include #else diff --git a/util.cpp b/util.cpp index b9b5858a..ba4249c3 100644 --- a/util.cpp +++ b/util.cpp @@ -65,9 +65,7 @@ #include #include -#if defined(LLVM_3_1) - #include -#elif defined(LLVM_3_2) +#if defined(LLVM_3_2) #include #else // LLVM 3.3+ #include @@ -616,13 +614,9 @@ VerifyDataLayoutCompatibility(const std::string &module_dl, // which contradic: f80:128:128 followed by f80:32:32. This is a bug, but // correct thing to do is to interpret this exactly how LLVM would treat it, // so we create a DataLayout class and take its string representation. -#if defined(LLVM_3_1) - llvm::TargetData d1(module_dl); - llvm::TargetData d2(lib_dl); -#else // LLVM 3.2+ + llvm::DataLayout d1(module_dl); llvm::DataLayout d2(lib_dl); -#endif std::string module_dl_canonic = d1.getStringRepresentation(); std::string lib_dl_canonic = d2.getStringRepresentation(); From 60fa76ccc12b36a0c51e583bb7b59c5e9a7c3cbd Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Fri, 1 Aug 2014 15:40:48 +0400 Subject: [PATCH 33/50] reversed macros LLVM_3_6 to LLVM_3_5+ in .cpp and .h files --- builtins.cpp | 7 ++++--- ctx.cpp | 2 +- ctx.h | 2 +- expr.cpp | 2 +- func.cpp | 8 +++++--- ispc.cpp | 2 +- main.cpp | 6 ++++-- module.cpp | 9 +++++---- module.h | 2 +- opt.cpp | 9 +++++---- type.cpp | 8 +++++--- 11 files changed, 33 insertions(+), 24 deletions(-) diff --git a/builtins.cpp b/builtins.cpp index 56b69447..87c5b55e 100644 --- a/builtins.cpp +++ b/builtins.cpp @@ -66,7 +66,7 @@ #include #include #endif -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ #include #else #include @@ -705,7 +705,8 @@ AddBitcodeToModule(const unsigned char *bitcode, int length, llvm::Module *module, SymbolTable *symbolTable) { llvm::StringRef sb = llvm::StringRef((char *)bitcode, length); llvm::MemoryBuffer *bcBuf = llvm::MemoryBuffer::getMemBuffer(sb); -#if defined(LLVM_3_5) || defined(LLVM_3_6) + +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ llvm::ErrorOr ModuleOrErr = llvm::parseBitcodeFile(bcBuf, *g->ctx); if (std::error_code EC = ModuleOrErr.getError()) Error(SourcePos(), "Error parsing stdlib bitcode: %s", EC.message().c_str()); @@ -762,7 +763,7 @@ AddBitcodeToModule(const unsigned char *bitcode, int length, // architecture and investigate what happened. // Generally we allow library DataLayout to be subset of module // DataLayout or library DataLayout to be empty. -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ if (!VerifyDataLayoutCompatibility(module->getDataLayoutStr(), bcModule->getDataLayoutStr())) { Warning(SourcePos(), "Module DataLayout is incompatible with " diff --git a/ctx.cpp b/ctx.cpp index b6d0d2c5..eb681d4c 100644 --- a/ctx.cpp +++ b/ctx.cpp @@ -1546,7 +1546,7 @@ FunctionEmitContext::StartScope() { llvm::DILexicalBlock lexicalBlock = m->diBuilder->createLexicalBlock(parentScope, diFile, currentPos.first_line, -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ // Revision 202736 in LLVM adds support of DWARF discriminator // to the last argument and revision 202737 in clang adds 0 // for the last argument by default. diff --git a/ctx.h b/ctx.h index 288b9af3..5df2e23c 100644 --- a/ctx.h +++ b/ctx.h @@ -47,7 +47,7 @@ #include #include #endif -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ #include #include #else diff --git a/expr.cpp b/expr.cpp index 8a82a1f8..80398ab5 100644 --- a/expr.cpp +++ b/expr.cpp @@ -74,7 +74,7 @@ #include #endif #include -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ #include #else #include diff --git a/func.cpp b/func.cpp index fb3a75b2..7412c560 100644 --- a/func.cpp +++ b/func.cpp @@ -69,7 +69,7 @@ #include #include #include -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ #include #include #include @@ -476,7 +476,8 @@ Function::GenerateIR() { } if (m->errorCount == 0) { -#if defined (LLVM_3_5) || defined(LLVM_3_6) + +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ if (llvm::verifyFunction(*function) == true) { #else if (llvm::verifyFunction(*function, llvm::ReturnStatusAction) == true) { @@ -523,7 +524,8 @@ Function::GenerateIR() { emitCode(&ec, appFunction, firstStmtPos); if (m->errorCount == 0) { sym->exportedFunction = appFunction; -#if defined(LLVM_3_5) || defined(LLVM_3_6) + +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ if (llvm::verifyFunction(*appFunction) == true) { #else if (llvm::verifyFunction(*appFunction, diff --git a/ispc.cpp b/ispc.cpp index 593b1452..b6d7b00a 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -57,7 +57,7 @@ #include #include #endif -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ #include #include #else diff --git a/main.cpp b/main.cpp index 256b5f4a..3510d548 100644 --- a/main.cpp +++ b/main.cpp @@ -166,7 +166,8 @@ devUsage(int ret) { printf(" disable-uniform-memory-optimizations\tDisable uniform-based coherent memory access\n"); printf(" [--yydebug]\t\t\t\tPrint debugging information during parsing\n"); printf(" [--debug-phase=]\t\tSet optimization phases to dump. --debug-phase=first,210:220,300,305,310:last\n"); -#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) + +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) // LLVM 3.4+ printf(" [--debug-ir=]\t\tSet optimization phase to generate debugIR after it\n"); #endif printf(" [--off-phase=]\t\tSwitch off optimization phases. --off-phase=first,210:220,300,305,310:last\n"); @@ -549,7 +550,8 @@ int main(int Argc, char *Argv[]) { "away or introduce the new ones.\n"); g->debug_stages = ParsingPhases(argv[i] + strlen("--debug-phase=")); } -#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) + +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) // LLVM 3.4+ else if (strncmp(argv[i], "--debug-ir=", 11) == 0) { g->debugIR = ParsingPhaseName(argv[i] + strlen("--debug-ir=")); } diff --git a/module.cpp b/module.cpp index e76c0c7c..a60a1490 100644 --- a/module.cpp +++ b/module.cpp @@ -93,7 +93,7 @@ #include #include #endif -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ #include #include #include @@ -939,7 +939,7 @@ Module::writeOutput(OutputType outputType, const char *outFileName, lStripUnusedDebugInfo(module); } -#if defined (LLVM_3_4) || defined (LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) // LLVM 3.4+ // In LLVM_3_4 after r195494 and r195504 revisions we should pass // "Debug Info Version" constant to the module. LLVM will ignore // our Debug Info metadata without it. @@ -1096,7 +1096,7 @@ Module::writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine, } llvm::PassManager pm; -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ pm.add(new llvm::DataLayoutPass(*g->target->getDataLayout())); #else pm.add(new llvm::DataLayout(*g->target->getDataLayout())); @@ -2093,7 +2093,8 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre } inst.getLangOpts().LineComment = 1; -#if defined(LLVM_3_5) || defined(LLVM_3_6) + +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ inst.createPreprocessor(clang::TU_Complete); #else inst.createPreprocessor(); diff --git a/module.h b/module.h index 04bc3e52..ad5f5a2e 100644 --- a/module.h +++ b/module.h @@ -44,7 +44,7 @@ #if defined(LLVM_3_4) #include #endif -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ #include #endif diff --git a/opt.cpp b/opt.cpp index 8e0b2c7e..a9f96a00 100644 --- a/opt.cpp +++ b/opt.cpp @@ -63,12 +63,12 @@ #include #include #endif -#if defined (LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) // LLVM 3.4+ #include #endif #include #include -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ #include #include #include @@ -444,7 +444,8 @@ DebugPassManager::add(llvm::Pass * P, int stage = -1) { number, P->getPassName()); PM.add(CreateDebugPass(buf)); } -#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) + +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) // LLVM 3.4+ if (g->debugIR == number) { // adding generating of LLVM IR debug after optimization char buf[100]; @@ -469,7 +470,7 @@ Optimize(llvm::Module *module, int optLevel) { new llvm::TargetLibraryInfo(llvm::Triple(module->getTargetTriple())); optPM.add(targetLibraryInfo); -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ optPM.add(new llvm::DataLayoutPass(*g->target->getDataLayout())); #else optPM.add(new llvm::DataLayout(*g->target->getDataLayout())); diff --git a/type.cpp b/type.cpp index eaa85dba..456a9520 100644 --- a/type.cpp +++ b/type.cpp @@ -50,7 +50,7 @@ #include #include #endif -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ #include #include #else @@ -2981,14 +2981,16 @@ FunctionType::GetDIType(llvm::DIDescriptor scope) const { for (int i = 0; i < GetNumParameters(); ++i) { const Type *t = GetParameterType(i); if (t == NULL) -#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) + +#if !defined(LLVM_3_2) && !defined(LLVM_3_3)// LLVM 3.4+ return llvm::DICompositeType(); #else return llvm::DIType(); #endif retArgTypes.push_back(t->GetDIType(scope)); } -#if defined(LLVM_3_6) + +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) // LLVM 3.6+ llvm::DITypeArray retArgTypesArray = m->diBuilder->getOrCreateTypeArray(llvm::ArrayRef(retArgTypes)); #else From d64e1bcd82de2cc93c7b30c34ddd6f98737ddf1a Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Fri, 1 Aug 2014 16:07:52 +0400 Subject: [PATCH 34/50] updated Makefile for reverce LLVM_3_6 flag --- Makefile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 412fc252..6e18366a 100644 --- a/Makefile +++ b/Makefile @@ -114,8 +114,8 @@ ifeq ($(LLVM_VERSION),LLVM_3_4) endif # There is no logical OR in GNU make. -# This 'ifneq' acts like if($(LLVM_VERSION) == LLVM_3_5 || $(LLVM_VERSION) == LLVM_3_6) -ifneq (,$(filter $(LLVM_VERSION), LLVM_3_5 LLVM_3_6)) +# This 'ifneq' acts like if( !($(LLVM_VERSION) == LLVM_3_2 || $(LLVM_VERSION) == LLVM_3_3 || $(LLVM_VERSION) == LLVM_3_4)) +ifeq (,$(filter $(LLVM_VERSION), LLVM_3_2 LLVM_3_3 LLVM_3_4)) ISPC_LIBS += -lcurses -lz endif @@ -153,10 +153,11 @@ CXXFLAGS=$(OPT) $(LLVM_CXXFLAGS) -I. -Iobjs/ -I$(CLANG_INCLUDE) \ -DBUILD_DATE="\"$(BUILD_DATE)\"" -DBUILD_VERSION="\"$(BUILD_VERSION)\"" \ -Wno-sign-compare -Wno-unused-function -Werror -# if($(LLVM_VERSION) == LLVM_3_5 || $(LLVM_VERSION) == LLVM_3_6) -ifneq (,$(filter $(LLVM_VERSION), LLVM_3_5 LLVM_3_6)) - CXXFLAGS+=-std=c++11 -Wno-c99-extensions -Wno-deprecated-register +# if( !($(LLVM_VERSION) == LLVM_3_2 || $(LLVM_VERSION) == LLVM_3_3 || $(LLVM_VERSION) == LLVM_3_4)) +ifeq (,$(filter $(LLVM_VERSION), LLVM_3_2 LLVM_3_3 LLVM_3_4)) + ISPC_LIBS += -lcurses -lz endif + ifneq ($(ARM_ENABLED), 0) CXXFLAGS+=-DISPC_ARM_ENABLED endif From 02e584d932fe799ce54d8a8dbbe2708c09009a29 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Fri, 1 Aug 2014 17:06:34 +0400 Subject: [PATCH 35/50] fixed broken Makefile (failed to build 3.5) --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 6e18366a..b30cc50e 100644 --- a/Makefile +++ b/Makefile @@ -155,9 +155,8 @@ CXXFLAGS=$(OPT) $(LLVM_CXXFLAGS) -I. -Iobjs/ -I$(CLANG_INCLUDE) \ # if( !($(LLVM_VERSION) == LLVM_3_2 || $(LLVM_VERSION) == LLVM_3_3 || $(LLVM_VERSION) == LLVM_3_4)) ifeq (,$(filter $(LLVM_VERSION), LLVM_3_2 LLVM_3_3 LLVM_3_4)) - ISPC_LIBS += -lcurses -lz + CXXFLAGS+=-std=c++11 -Wno-c99-extensions -Wno-deprecated-register endif - ifneq ($(ARM_ENABLED), 0) CXXFLAGS+=-DISPC_ARM_ENABLED endif From 10f00c6e4cd2c86d11fa85fd4cfb7279e2e94baa Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Fri, 1 Aug 2014 17:12:21 +0400 Subject: [PATCH 36/50] removed LLVM 3.1 option from python scripts --- alloy.py | 11 ++++------- run_tests.py | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/alloy.py b/alloy.py index 4adb060d..238dd924 100755 --- a/alloy.py +++ b/alloy.py @@ -123,9 +123,6 @@ def build_LLVM(version_LLVM, revision, folder, tarball, debug, selfbuild, extra, if version_LLVM == "3.2": SVN_PATH="tags/RELEASE_32/final" version_LLVM = "3_2" - if version_LLVM == "3.1": - SVN_PATH="tags/RELEASE_31/final" - version_LLVM = "3_1" if revision != "": FOLDER_NAME = FOLDER_NAME + "_" + revision revision = "-" + revision @@ -459,7 +456,7 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, archs.append("x86-64") if "native" in only: sde_targets_t = [] - for i in ["3.1", "3.2", "3.3", "3.4", "3.5", "trunk"]: + for i in ["3.2", "3.3", "3.4", "3.5", "trunk"]: if i in only: LLVM.append(i) if "current" in only: @@ -712,7 +709,7 @@ def Main(): if os.environ.get("SMTP_ISPC") == None: error("you have no SMTP_ISPC in your environment for option notify", 1) if options.only != "": - test_only_r = " 3.1 3.2 3.3 3.4 3.5 trunk current build stability performance x86 x86-64 -O0 -O2 native " + test_only_r = " 3.2 3.3 3.4 3.5 trunk current build stability performance x86 x86-64 -O0 -O2 native " test_only = options.only.split(" ") for iterator in test_only: if not (" " + iterator + " " in test_only_r): @@ -821,7 +818,7 @@ if __name__ == '__main__': llvm_group = OptionGroup(parser, "Options for building LLVM", "These options must be used with -b option.") llvm_group.add_option('--version', dest='version', - help='version of llvm to build: 3.1 3.2 3.3 3.4 3.5 trunk. Default: trunk', default="trunk") + help='version of llvm to build: 3.2 3.3 3.4 3.5 trunk. Default: trunk', default="trunk") llvm_group.add_option('--revision', dest='revision', help='revision of llvm to build in format r172870', default="") llvm_group.add_option('--debug', dest='debug', @@ -856,7 +853,7 @@ if __name__ == '__main__': run_group.add_option('--only', dest='only', help='set types of tests. Possible values:\n' + '-O0, -O2, x86, x86-64, stability (test only stability), performance (test only performance)\n' + - 'build (only build with different LLVM), 3.1, 3.2, 3.3, 3.4 3.5, trunk, native (do not use SDE), current (do not rebuild ISPC).', + 'build (only build with different LLVM), 3.2, 3.3, 3.4 3.5, trunk, native (do not use SDE), current (do not rebuild ISPC).', default="") run_group.add_option('--perf_LLVM', dest='perf_llvm', help='compare LLVM 3.3 with "--compare-with", default trunk', default=False, action='store_true') diff --git a/run_tests.py b/run_tests.py index 8644545a..363ae5cd 100755 --- a/run_tests.py +++ b/run_tests.py @@ -481,7 +481,7 @@ def verify(): f_lines = f.readlines() f.close() check = [["g++", "clang++", "cl"],["-O0", "-O2"],["x86","x86-64"], - ["Linux","Windows","Mac"],["LLVM 3.1","LLVM 3.2","LLVM 3.3","LLVM 3.4","LLVM trunk"], + ["Linux","Windows","Mac"],["LLVM 3.2","LLVM 3.3","LLVM 3.4","LLVM 3.5","LLVM trunk"], ["sse2-i32x4", "sse2-i32x8", "sse4-i32x4", "sse4-i32x8", "sse4-i16x8", "sse4-i8x16", "avx1-i32x4" "avx1-i32x8", "avx1-i32x16", "avx1-i64x4", "avx1.1-i32x8", "avx1.1-i32x16", "avx1.1-i64x4", "avx2-i32x8", "avx2-i32x16", "avx2-i64x4", From 3dafbc4516e079a830d89ecd701ff28e0345f72a Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Fri, 1 Aug 2014 17:30:30 +0400 Subject: [PATCH 37/50] remover LLVM 3_1 from cbackend.cpp --- cbackend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cbackend.cpp b/cbackend.cpp index 31ad01a7..867385a4 100644 --- a/cbackend.cpp +++ b/cbackend.cpp @@ -106,7 +106,7 @@ #include "llvm/Support/Host.h" #include "llvm/Target/TargetMachine.h" -#if defined(LLVM_3_1) || defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) +#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) #include "llvm/Config/config.h" #endif From b292cffa4aca01c892385cec9f894292376ab50c Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Tue, 5 Aug 2014 12:31:08 +0400 Subject: [PATCH 38/50] changed 3.5 repo path from tag to branch until rc2 is out --- alloy.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/alloy.py b/alloy.py index 238dd924..c18089d5 100755 --- a/alloy.py +++ b/alloy.py @@ -112,7 +112,8 @@ def build_LLVM(version_LLVM, revision, folder, tarball, debug, selfbuild, extra, if version_LLVM == "trunk": SVN_PATH="trunk" if version_LLVM == "3.5": - SVN_PATH="tags/RELEASE_35/rc1" + # SVN_PATH=/tags/RELEASE_35/rc1 + SVN_PATH="branches/release_35" version_LLVM = "3_5" if version_LLVM == "3.4": SVN_PATH="tags/RELEASE_34/dot2-final" From 02e08892b34a2157d8e4643e4357291708d4c556 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Tue, 5 Aug 2014 12:39:46 +0400 Subject: [PATCH 39/50] tail the run_tests.log (100 lines) --- alloy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alloy.py b/alloy.py index 238dd924..e1e52028 100755 --- a/alloy.py +++ b/alloy.py @@ -583,7 +583,7 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, print_debug("\t\t\t" + temp5[1][i][k], True, stability_log) print_debug("__________________Watch stability.log for details_________________\n", False, stability_log) if options.notify != "": - attach_mail_file(msg, stability.in_file, "run_tests_log.log") + attach_mail_file(msg, stability.in_file, "run_tests_log.log", 100) attach_mail_file(msg, stability_log, "stability.log") # *** *** *** From d44c4c05aa15bdf1641995847183b1d1fee3f3ad Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Tue, 5 Aug 2014 13:32:04 +0400 Subject: [PATCH 40/50] removed leading slash in a comment --- alloy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alloy.py b/alloy.py index c18089d5..513b01b5 100755 --- a/alloy.py +++ b/alloy.py @@ -112,7 +112,7 @@ def build_LLVM(version_LLVM, revision, folder, tarball, debug, selfbuild, extra, if version_LLVM == "trunk": SVN_PATH="trunk" if version_LLVM == "3.5": - # SVN_PATH=/tags/RELEASE_35/rc1 + # SVN_PATH=tags/RELEASE_35/rc1 SVN_PATH="branches/release_35" version_LLVM = "3_5" if version_LLVM == "3.4": From 6f3f4ff4a123496ac0ab5ac0b511ab936d24f3c7 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Tue, 5 Aug 2014 16:18:11 +0400 Subject: [PATCH 41/50] add separate test fail count for each LLVM revision --- alloy.py | 72 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 24 deletions(-) diff --git a/alloy.py b/alloy.py index 238dd924..f2058a3f 100755 --- a/alloy.py +++ b/alloy.py @@ -369,7 +369,7 @@ def execute_stability(stability, R, print_version): temp = b_temp[0] time = b_temp[1] for j in range(0,4): - R[j][0] = R[j][0] + temp[j] + R[j][0] = R[j][0] + temp[j] # new_runfails, new_compfails, new_passes_runfails, new_passes_compfails for i in range(0,len(temp[j])): R[j][1].append(temp[4]) number_of_fails = temp[5] @@ -393,6 +393,42 @@ def execute_stability(stability, R, print_version): str_time = "\n" print_debug(temp[4][1:-3] + str_fails + str_new_fails + str_new_passes + str_time, False, stability_log) +''' +R = [[new_runfails, [new_line, new_line...]], + [new_compfails, [new_line, new_line...]], + [new_passes_runfails, [new_line, new_line...]], + [new_passes_runfails, [new_line, new_line...]]] +''' +def output_test_results(R): + ttt = ["NEW RUNFAILS: ", "NEW COMPFAILS: ", "NEW PASSES RUNFAILS: ", "NEW PASSES COMPFAILS: "] + for j in range(0, 4): + if len(R[j][0]) == 0: + print_debug("NO " + ttt[j][:-2] + "\n", False, stability_log) + else: + print_debug(ttt[j] + str(len(R[j][0])) + "\n", False, stability_log) + to_print = {} + for (fail_name, opt_str) in zip(R[j][0], R[j][1]): + if fail_name not in to_print: + to_print[fail_name] = [] + to_print[fail_name].append(opt_str) + + # sort + for key in to_print.keys(): + to_print[key] = sorted(to_print[key]) + + # print out + for fail_name in sorted(to_print.keys()): + print_debug("\t" + fail_name + "\n", True, stability_log) + for opt_str in to_print[fail_name]: + print_debug("\t\t\t" + opt_str, True, stability_log) + +def concatenate_test_results(R1, R2): + R = [[[],[]],[[],[]],[[],[]],[[],[]]] + for j in range(0, 4): + R[j][0] = R1[j][0] + R2[j][0] + R[j][1] = R1[j][1] + R2[j][1] + return R + def run_special_tests(): i = 5 @@ -520,6 +556,7 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, print_debug("\n" + common.get_host_name() + "\n", False, stability_log) print_debug("\n_________________________STABILITY REPORT_________________________\n", False, stability_log) for i in range(0,len(LLVM)): + R_tmp = [[[],[]],[[],[]],[[],[]],[[],[]]] print_version = 2 if rebuild: build_ispc(LLVM[i], make) @@ -545,7 +582,7 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, stability.arch = arch[i1] stability.no_opt = opts[i2] try: - execute_stability(stability, R, print_version) + execute_stability(stability, R_tmp, print_version) except: print_debug("Exception in execute_stability - maybe some test subprocess terminated before it should have\n", False, stability_log) print_version = 0 @@ -556,31 +593,18 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, for i2 in range(0,len(opts)): stability.arch = archs[i1] stability.no_opt = opts[i2] - execute_stability(stability, R, print_version) + execute_stability(stability, R_tmp, print_version) print_version = 0 + + # Output testing results separate for each tested LLVM version + R = concatenate_test_results(R, R_tmp) + output_test_results(R_tmp) # run special tests like embree # - run_special_tests() - ttt = ["NEW RUNFAILS: ", "NEW COMPFAILS: ", "NEW PASSES RUNFAILS: ", "NEW PASSES COMPFAILS: "] - for j in range(0,4): - if len(R[j][0]) == 0: - print_debug("NO " + ttt[j][:-2] + "\n", False, stability_log) - else: - print_debug(ttt[j] + str(len(R[j][0])) + "\n", False, stability_log) - temp5 = [[],[]] - for i in range(0,len(R[j][0])): - er = True - for k in range(0,len(temp5[0])): - if R[j][0][i] == temp5[0][k]: - temp5[1][k].append(R[j][1][i]) - er = False - if er == True: - temp5[0].append(R[j][0][i]) - temp5[1].append([R[j][1][i]]) - for i in range(0,len(temp5[0])): - print_debug("\t" + temp5[0][i] + "\n", True, stability_log) - for k in range(0,len(temp5[1][i])): - print_debug("\t\t\t" + temp5[1][i][k], True, stability_log) + run_special_tests() # dead code? + + print_debug("TOTAL:\n", False, stability_log) + output_test_results(R) print_debug("__________________Watch stability.log for details_________________\n", False, stability_log) if options.notify != "": attach_mail_file(msg, stability.in_file, "run_tests_log.log") From c1f5a8d8ae35b140bd837d15bbb864bcdcfc5e01 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Tue, 5 Aug 2014 16:19:16 +0400 Subject: [PATCH 42/50] made text look more beautiful --- alloy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alloy.py b/alloy.py index f2058a3f..60904063 100755 --- a/alloy.py +++ b/alloy.py @@ -603,7 +603,7 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, # run_special_tests() # dead code? - print_debug("TOTAL:\n", False, stability_log) + print_debug("\n\nTOTAL:\n", False, stability_log) output_test_results(R) print_debug("__________________Watch stability.log for details_________________\n", False, stability_log) if options.notify != "": From f98038a03cd5ee83cea79221e20dc0eab10ab7ce Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Wed, 6 Aug 2014 09:36:47 +0400 Subject: [PATCH 43/50] removed some dead code --- alloy.py | 11 ++--------- common.py | 3 ++- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/alloy.py b/alloy.py index 80576508..2f97a01e 100755 --- a/alloy.py +++ b/alloy.py @@ -394,11 +394,6 @@ def execute_stability(stability, R, print_version): str_time = "\n" print_debug(temp[4][1:-3] + str_fails + str_new_fails + str_new_passes + str_time, False, stability_log) -def run_special_tests(): - i = 5 - -class options_for_drivers: - pass def validation_run(only, only_targets, reference_branch, number, notify, update, speed_number, make, perf_llvm, time): os.chdir(os.environ["ISPC_HOME"]) @@ -417,7 +412,7 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, # *** *** *** if ((("stability" in only) == True) or ("performance" in only) == False): print_debug("\n\nStability validation run\n\n", False, "") - stability = options_for_drivers() + stability = common.EmptyClass() # stability constant options stability.save_bin = False stability.random = False @@ -559,9 +554,7 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, stability.no_opt = opts[i2] execute_stability(stability, R, print_version) print_version = 0 -# run special tests like embree -# - run_special_tests() + ttt = ["NEW RUNFAILS: ", "NEW COMPFAILS: ", "NEW PASSES RUNFAILS: ", "NEW PASSES COMPFAILS: "] for j in range(0,4): if len(R[j][0]) == 0: diff --git a/common.py b/common.py index 55f998bf..c7cb731c 100755 --- a/common.py +++ b/common.py @@ -37,7 +37,8 @@ import os import errno import shutil - +# generic empty class +class EmptyClass(object): pass # load/save almost every object to a file (good for bug reproducing) def dump(fname, obj): From 898a56c53b7b725b9f6fa3969971d6cd130a309e Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Wed, 6 Aug 2014 10:52:23 +0400 Subject: [PATCH 44/50] added fail counters to the top of the message body --- alloy.py | 79 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 29 deletions(-) diff --git a/alloy.py b/alloy.py index 9e402237..14e14a2a 100755 --- a/alloy.py +++ b/alloy.py @@ -88,9 +88,8 @@ def try_do_LLVM(text, command, from_validation): print_debug("ERROR.\n", from_validation, alloy_build) if options.notify != "": msg = MIMEMultipart() - attach_mail_file(msg, alloy_build, "alloy_build.log", 400) attach_mail_file(msg, stability_log, "stability.log") - send_mail("Error while executing " + command + ". Examine logs for more information.", msg) + send_mail("ERROR: Error while executing " + command + ". Examine logs for more information.", msg) error("can't " + text, 1) print_debug("DONE.\n", from_validation, alloy_build) @@ -104,7 +103,6 @@ def build_LLVM(version_LLVM, revision, folder, tarball, debug, selfbuild, extra, current_path = os.getcwd() llvm_home = os.environ["LLVM_HOME"] - make_sure_dir_exists(llvm_home) os.chdir(llvm_home) @@ -330,15 +328,26 @@ def build_ispc(version_LLVM, make): folder += version_LLVM if options.debug == True: folder += "dbg" - + + + llvm_rev = "" + # determine LLVM revision p = subprocess.Popen("svn info " + folder, shell=True, \ stdout=subprocess.PIPE, stderr=subprocess.PIPE) (info_llvm, err) = p.communicate() info_llvm = re.split('\n', info_llvm) for i in info_llvm: if len(i) > 0 and i.startswith("Last Changed Rev: "): - common.ex_state.switch_revision(str(i[len("Last Changed Rev: "):])) + llvm_rev = str(i[len("Last Changed Rev: "):]) + if llvm_rev != "": + common.ex_state.switch_revision(llvm_rev) + print_debug("\n----------------------------------------\nBuilding ISPC with LLVM" \ + + llvm_rev + ":\n", False, stability_log) + else: + print_debug("Unable to retrieve LLVM revision\n", False, stability_log) + raise + try_do_LLVM("recognize LLVM revision", "svn info " + folder, True) try_do_LLVM("build ISPC with LLVM version " + version_LLVM + " ", make_ispc, True) os.environ["PATH"] = p_temp @@ -448,6 +457,7 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, date = datetime.datetime.now() print_debug("Date: " + date.strftime('%H:%M %d/%m/%Y') + "\n", False, "") newest_LLVM="3.4" + msg_additional_info = "" # *** *** *** # Stability validation run # *** *** *** @@ -585,7 +595,7 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, try: execute_stability(stability, R_tmp, print_version) except: - print_debug("Exception in execute_stability - maybe some test subprocess terminated before it should have\n", False, stability_log) + print_debug("ERROR: Exception in execute_stability - maybe some test subprocess terminated before it should have\n", False, stability_log) print_version = 0 for j in range(0,len(sde_targets)): stability.target = sde_targets[j][1] @@ -600,14 +610,18 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, # Output testing results separate for each tested LLVM version R = concatenate_test_results(R, R_tmp) output_test_results(R_tmp) + print_debug("\n", False, stability_log) # run special tests like embree # run_special_tests() # dead code? - print_debug("\n\nTOTAL:\n", False, stability_log) + print_debug("\n----------------------------------------\nTOTAL:\n", False, stability_log) output_test_results(R) print_debug("__________________Watch stability.log for details_________________\n", False, stability_log) if options.notify != "": + # e-mail header for performance test: + msg_additional_info += "New runfails(%d) New compfails(%d) New passes runfails(%d)" + \ + "New passes compfails(%d)" % (len(R[0][0]), len(R[1][0]), len(R[2][0]), len(R[3][0])) attach_mail_file(msg, stability.in_file, "run_tests_log.log", 100) attach_mail_file(msg, stability_log, "stability.log") @@ -667,39 +681,46 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, build_ispc(newest_LLVM, make) os.rename("ispc", "ispc_ref") build_ispc(reference_branch, make) -# begin validation run for performance. output is inserted into perf() + # begin validation run for performance. output is inserted into perf() perf.perf(performance, []) if options.notify != "": attach_mail_file(msg, performance.in_file, "performance.log") attach_mail_file(msg, "." + os.sep + "logs" + os.sep + "perf_build.log", "perf_build.log") -# dumping gathered info to the file + # dumping gathered info to the file common.ex_state.dump(alloy_folder + "test_table.dump", common.ex_state.tt) -# sending e-mail with results + + # sending e-mail with results if options.notify != "": + send_mail(msg_additional_info, msg) + +def send_mail(body_header, msg): + try: fp = open(os.environ["ISPC_HOME"] + os.sep + "notify_log.log", 'rb') f_lines = fp.readlines() fp.close() - body = "" - body += "Hostname: " + common.get_host_name() + "\n\n" + except: + body_header += "\nUnable to open notify_log.log: " + str(sys.exc_info()) + "\n" + print_debug("Unable to open notify_log.log: " + str(sys.exc_info()) + "\n", False, stability_log) + + body = "Hostname: " + common.get_host_name() + "\n\n" - if not sys.exc_info()[0] == None: - body = body + "Last exception: " + str(sys.exc_info()) + '\n' - for i in range(0,len(f_lines)): - body = body + f_lines[i][:-1] - body = body + ' \n' - attach_mail_file(msg, alloy_build, "alloy_build.log", 100) - send_mail(body, msg) + if not sys.exc_info()[0] == None: + body += "ERROR: Exception(last) - " + str(sys.exc_info()) + '\n' + for i in range(0, len(f_lines)): + body += f_lines[i][:-1] + body += ' \n' -def send_mail(body, msg): - smtp_server = os.environ["SMTP_ISPC"] - msg['Subject'] = "ISPC test system results" - msg['From'] = "ISPC_test_system" - msg['To'] = options.notify - text = MIMEText(body, "", "KOI-8") - msg.attach(text) - s = smtplib.SMTP(smtp_server) - s.sendmail(options.notify, options.notify.split(" "), msg.as_string()) - s.quit() + body += body_header + '\n' + attach_mail_file(msg, alloy_build, "alloy_build.log", 100) # build.log is always being sent + smtp_server = os.environ["SMTP_ISPC"] + msg['Subject'] = "ISPC test system results" + msg['From'] = "ISPC_test_system" + msg['To'] = options.notify + text = MIMEText(body, "", "KOI-8") + msg.attach(text) + s = smtplib.SMTP(smtp_server) + s.sendmail(options.notify, options.notify.split(" "), msg.as_string()) + s.quit() def Main(): global current_OS From 3ebc80ade6e945b132d005324a00f9a072783ae6 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Wed, 6 Aug 2014 10:56:37 +0400 Subject: [PATCH 45/50] fixed unresolved class use --- alloy.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/alloy.py b/alloy.py index be3d23be..c4847427 100755 --- a/alloy.py +++ b/alloy.py @@ -529,7 +529,6 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, targets = targets_t + targets_generic_t[:-4] sde_targets = sde_targets_t - if "build" in only: targets = [] sde_targets = [] @@ -608,7 +607,7 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, if ((("performance" in only) == True) or ("stability" in only) == False): print_debug("\n\nPerformance validation run\n\n", False, "") common.check_tools(1) - performance = options_for_drivers() + performance = common.EmptyClass() # performance constant options performance.number = number performance.config = "." + os.sep + "perf.ini" From ab91a9073467c0c4a5ca97fe4bf5fb89a5f3a8e3 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Wed, 6 Aug 2014 12:28:59 +0400 Subject: [PATCH 46/50] some minor changes --- alloy.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/alloy.py b/alloy.py index 14e14a2a..ae767064 100755 --- a/alloy.py +++ b/alloy.py @@ -89,7 +89,7 @@ def try_do_LLVM(text, command, from_validation): if options.notify != "": msg = MIMEMultipart() attach_mail_file(msg, stability_log, "stability.log") - send_mail("ERROR: Error while executing " + command + ". Examine logs for more information.", msg) + send_mail("ERROR: Non-zero exit status while executing " + command + ". Examine build log for more information.", msg) error("can't " + text, 1) print_debug("DONE.\n", from_validation, alloy_build) @@ -342,8 +342,8 @@ def build_ispc(version_LLVM, make): if llvm_rev != "": common.ex_state.switch_revision(llvm_rev) - print_debug("\n----------------------------------------\nBuilding ISPC with LLVM" \ - + llvm_rev + ":\n", False, stability_log) + print_debug("\nBuilding ISPC with LLVM %s (%s):\n" \ + % (version_LLVM, llvm_rev), False, stability_log) else: print_debug("Unable to retrieve LLVM revision\n", False, stability_log) raise @@ -620,8 +620,8 @@ def validation_run(only, only_targets, reference_branch, number, notify, update, print_debug("__________________Watch stability.log for details_________________\n", False, stability_log) if options.notify != "": # e-mail header for performance test: - msg_additional_info += "New runfails(%d) New compfails(%d) New passes runfails(%d)" + \ - "New passes compfails(%d)" % (len(R[0][0]), len(R[1][0]), len(R[2][0]), len(R[3][0])) + msg_additional_info += "New runfails(%d) New compfails(%d) New passes runfails(%d) New passes compfails(%d)" \ + % (len(R[0][0]), len(R[1][0]), len(R[2][0]), len(R[3][0])) attach_mail_file(msg, stability.in_file, "run_tests_log.log", 100) attach_mail_file(msg, stability_log, "stability.log") @@ -706,11 +706,12 @@ def send_mail(body_header, msg): if not sys.exc_info()[0] == None: body += "ERROR: Exception(last) - " + str(sys.exc_info()) + '\n' + + body += body_header + '\n' for i in range(0, len(f_lines)): body += f_lines[i][:-1] body += ' \n' - body += body_header + '\n' attach_mail_file(msg, alloy_build, "alloy_build.log", 100) # build.log is always being sent smtp_server = os.environ["SMTP_ISPC"] msg['Subject'] = "ISPC test system results" From bfad04d648925ae83d3d6eecdc76778a2ac2fe60 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Wed, 6 Aug 2014 11:56:35 +0400 Subject: [PATCH 47/50] fix for build fail after llvm commit 214781 --- ispc.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ispc.cpp b/ispc.cpp index b6d7b00a..0a0df702 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -57,10 +57,13 @@ #include #include #endif +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) // LLVM 3.6+ + #include +#endif #if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ #include #include -#else +#else // LLVM 3.2, 3.3, 3.4 #include #include #endif @@ -656,8 +659,12 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) : // Initialize TargetData/DataLayout in 3 steps. // 1. Get default data layout first std::string dl_string; - dl_string = m_targetMachine->getDataLayout()->getStringRepresentation(); +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) // LLVM 3.6+ + dl_string = m_targetMachine->getSubtargetImpl()->getDataLayout()->getStringRepresentation(); +#else + dl_string = m_targetMachine->getDataLayout()->getStringRepresentation(); +#endif // 2. Adjust for generic if (m_isa == Target::GENERIC) { // <16 x i1> vectors only need 16 bit / 2 byte alignment, so add @@ -677,6 +684,7 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic) : // This indicates if we are compiling for 32 bit platform // and can assume 32 bit runtime. // FIXME: all generic targets are handled as 64 bit, which is incorrect. + this->m_is32Bit = (getDataLayout()->getPointerSize() == 4); #if !defined(LLVM_3_2) From fbccf0f8b0a735f9f8ba857b12094f548fecec54 Mon Sep 17 00:00:00 2001 From: Andrey Guskov Date: Wed, 6 Aug 2014 20:23:54 +0400 Subject: [PATCH 48/50] made multithreading work correctly on Windows by waiting on a queue instead of thread join() loop --- run_tests.py | 75 +++++++++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/run_tests.py b/run_tests.py index 363ae5cd..04cede43 100755 --- a/run_tests.py +++ b/run_tests.py @@ -297,8 +297,8 @@ def run_test(testname): # pull tests to run from the given queue and run them. Multiple copies of # this function will be running in parallel across all of the CPU cores of # the system. -def run_tasks_from_queue(queue, queue_ret, queue_skip, total_tests_arg, max_test_length_arg, counter, mutex, glob_var): - # This is needed on windows because windows doen't copy globals from parent process whili multiprocessing +def run_tasks_from_queue(queue, queue_ret, queue_error, queue_finish, total_tests_arg, max_test_length_arg, counter, mutex, glob_var): + # This is needed on windows because windows doesn't copy globals from parent process while multiprocessing global is_windows is_windows = glob_var[0] global options @@ -321,13 +321,37 @@ def run_tasks_from_queue(queue, queue_ret, queue_skip, total_tests_arg, max_test else: olddir = "" + queue_error.put('ERROR') compile_error_files = [ ] run_succeed_files = [ ] run_error_files = [ ] skip_files = [ ] + while True: - filename = queue.get() - if (filename == 'STOP'): + if not queue.empty(): + filename = queue.get() + if check_test(filename): + try: + (compile_error, run_error) = run_test(filename) + except: + print_debug("ERROR: run_test function raised an exception: %s\n" % (sys.exc_info()[1]), s, run_tests_log) + queue_finish.get() + queue_finish.task_done() + break # This is in case the child has unexpectedly died or some other exception happened + + if compile_error == 0 and run_error == 0: + run_succeed_files += [ filename ] + if compile_error != 0: + compile_error_files += [ filename ] + if run_error != 0: + run_error_files += [ filename ] + + with mutex: + update_progress(filename, total_tests_arg, counter, max_test_length_arg) + else: + skip_files += [ filename ] + + else: queue_ret.put((compile_error_files, run_error_files, skip_files, run_succeed_files)) if is_windows: try: @@ -341,27 +365,11 @@ def run_tasks_from_queue(queue, queue_ret, queue_skip, total_tests_arg, max_test os.rmdir(tmpdir) except: None - - sys.exit(0) - if check_test(filename): - try: - (compile_error, run_error) = run_test(filename) - except: - print_debug("ERROR: run_test function raised an exception: %s\n" % (sys.exc_info()[1]), s, run_tests_log) - sys.exit(-1) # This is in case the child has unexpectedly died or some other exception happened - - if compile_error == 0 and run_error == 0: - run_succeed_files += [ filename ] - if compile_error != 0: - compile_error_files += [ filename ] - if run_error != 0: - run_error_files += [ filename ] - - with mutex: - update_progress(filename, total_tests_arg, counter, max_test_length_arg) - else: - skip_files += [ filename ] + queue_error.get() + queue_finish.get() + queue_finish.task_done() + break def sigint(signum, frame): @@ -684,10 +692,12 @@ def run_tests(options1, args, print_version): q = multiprocessing.Queue() for fn in files: q.put(fn) - for x in range(nthreads): - q.put('STOP') qret = multiprocessing.Queue() - qskip = multiprocessing.Queue() + qerr = multiprocessing.Queue() + qfin = multiprocessing.JoinableQueue() + + for x in range(nthreads): + qfin.put('STOP') # need to catch sigint so that we can terminate all of the tasks if # we're interrupted @@ -702,14 +712,14 @@ def run_tests(options1, args, print_version): global task_threads task_threads = [0] * nthreads for x in range(nthreads): - task_threads[x] = multiprocessing.Process(target=run_tasks_from_queue, args=(q, qret, qskip, total_tests, + task_threads[x] = multiprocessing.Process(target=run_tasks_from_queue, args=(q, qret, qerr, qfin, total_tests, max_test_length, finished_tests_counter, finished_tests_counter_lock, glob_var)) task_threads[x].start() # wait for them to all finish and then return the number that failed # (i.e. return 0 if all is ok) - for t in task_threads: - t.join() + qfin.join() + if options.non_interactive == False: print_debug("\n", s, run_tests_log) @@ -752,9 +762,8 @@ def run_tests(options1, args, print_version): - for jb in task_threads: - if not jb.exitcode == 0: - raise OSError(2, 'Some test subprocess has thrown an exception', '') + if not qerr.empty(): + raise OSError(2, 'Some test subprocess has thrown an exception', '') if options.non_interactive: print_debug(" Done %d / %d\n" % (finished_tests_counter.value, total_tests), s, run_tests_log) From f87ecf0573222cdaab4703734659f7587113026f Mon Sep 17 00:00:00 2001 From: Andrey Guskov Date: Thu, 7 Aug 2014 19:28:15 +0400 Subject: [PATCH 49/50] added comments to the fix --- run_tests.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/run_tests.py b/run_tests.py index 04cede43..0f2ae3d2 100755 --- a/run_tests.py +++ b/run_tests.py @@ -320,7 +320,8 @@ def run_tasks_from_queue(queue, queue_ret, queue_error, queue_finish, total_test os.chdir(tmpdir) else: olddir = "" - + + # by default, the thread is presumed to fail queue_error.put('ERROR') compile_error_files = [ ] run_succeed_files = [ ] @@ -334,10 +335,15 @@ def run_tasks_from_queue(queue, queue_ret, queue_error, queue_finish, total_test try: (compile_error, run_error) = run_test(filename) except: + # This is in case the child has unexpectedly died or some other exception happened + # it`s not what we wanted, so we leave ERROR in queue_error print_debug("ERROR: run_test function raised an exception: %s\n" % (sys.exc_info()[1]), s, run_tests_log) + # minus one thread, minus one STOP queue_finish.get() + # needed for queue join queue_finish.task_done() - break # This is in case the child has unexpectedly died or some other exception happened + # exiting the loop, returning from the thread + break if compile_error == 0 and run_error == 0: run_succeed_files += [ filename ] @@ -366,9 +372,14 @@ def run_tasks_from_queue(queue, queue_ret, queue_error, queue_finish, total_test except: None + # the next line is crucial for error indication! + # this thread ended correctly, so take ERROR back queue_error.get() + # minus one thread, minus one STOP queue_finish.get() + # needed for queue join queue_finish.task_done() + # exiting the loop, returning from the thread break @@ -692,10 +703,14 @@ def run_tests(options1, args, print_version): q = multiprocessing.Queue() for fn in files: q.put(fn) + # qret is a queue for returned data qret = multiprocessing.Queue() + # qerr is an error indication queue qerr = multiprocessing.Queue() + # qfin is a waiting queue: JoinableQueue has join() and task_done() methods qfin = multiprocessing.JoinableQueue() + # for each thread, there is a STOP in qfin to synchronize execution for x in range(nthreads): qfin.put('STOP') @@ -716,8 +731,8 @@ def run_tests(options1, args, print_version): max_test_length, finished_tests_counter, finished_tests_counter_lock, glob_var)) task_threads[x].start() - # wait for them to all finish and then return the number that failed - # (i.e. return 0 if all is ok) + # wait for them all to finish and rid the queue of STOPs + # join() here just waits for synchronization qfin.join() if options.non_interactive == False: @@ -762,6 +777,7 @@ def run_tests(options1, args, print_version): + # if all threads ended correctly, qerr is empty if not qerr.empty(): raise OSError(2, 'Some test subprocess has thrown an exception', '') From 8a72e23b29ede434556b7d78736323c1879a2791 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Mon, 11 Aug 2014 11:11:30 +0400 Subject: [PATCH 50/50] 'notify.log' trashing removed --- alloy.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/alloy.py b/alloy.py index 5b73ad02..080033c3 100755 --- a/alloy.py +++ b/alloy.py @@ -737,6 +737,11 @@ def Main(): parser.print_help() exit(0) + if options.notify != "": + # in case 'notify' option is used but build (in '-b' for example) failed we do not want to have trash in our message body + # NOTE! 'notify.log' must also be cleaned up at the beginning of every message sending function, i.e. in 'validation_run()' + common.remove_if_exists(os.environ["ISPC_HOME"] + os.sep + "notify_log.log") + setting_paths(options.llvm_home, options.ispc_home, options.sde_home) if os.environ.get("LLVM_HOME") == None: error("you have no LLVM_HOME", 1)