Merge pull request #23943 from gottesmm/pr-5f0e58774d6cdc3eea4498b84255f8293e0bd665

diff --git a/benchmark/scripts/build_script_helper.py b/benchmark/scripts/build_script_helper.py
new file mode 100755
index 0000000..1cd61ce
--- /dev/null
+++ b/benchmark/scripts/build_script_helper.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+
+from __future__ import print_function
+
+import argparse
+import os
+import shutil
+import subprocess
+
+
+def perform_build(args, swiftbuild_path, config, binary_name, opt_flag):
+    assert(config in ['debug', 'release'])
+    assert(binary_name in ['Benchmark_O', 'Benchmark_Onone'])
+    assert(opt_flag in ['-O', '-Onone'])
+
+    inner_build_dir = os.path.join(args.build_path, binary_name)
+    swiftbuild_args = [
+        swiftbuild_path,
+        '--package-path', args.package_path,
+        '--build-path', inner_build_dir,
+        '--configuration', config,
+        '-Xswiftc', '-Xllvm',
+        '-Xswiftc', '-align-module-to-page-size',
+        '-Xswiftc', opt_flag,
+    ]
+    if args.verbose:
+        swiftbuild_args.append('--verbose')
+    subprocess.call(swiftbuild_args)
+
+    # Copy the benchmark file into the final ./bin directory.
+    binpath = os.path.join(inner_build_dir, config, 'SwiftBench')
+    finalpath = os.path.join(args.build_path, 'bin', binary_name)
+    shutil.copy(binpath, finalpath)
+
+
+def main():
+    parser = argparse.ArgumentParser()
+    parser.add_argument('--verbose', '-v', action='store_true')
+    parser.add_argument('--package-path', type=str, required=True)
+    parser.add_argument('--build-path', type=str, required=True)
+    parser.add_argument('--toolchain', type=str, required=True)
+
+    args = parser.parse_args()
+
+    # Create our bin directory so we can copy in the binaries.
+    bin_dir = os.path.join(args.build_path, 'bin')
+    if not os.path.isdir(bin_dir):
+        os.makedirs(bin_dir)
+
+    swiftbuild_path = os.path.join(args.toolchain, 'usr', 'bin', 'swift-build')
+    perform_build(args, swiftbuild_path, 'debug', 'Benchmark_Onone', '-Onone')
+    perform_build(args, swiftbuild_path, 'release', 'Benchmark_O', '-O')
+
+
+if __name__ == "__main__":
+    main()
diff --git a/benchmark/utils/build_script_helper.py b/benchmark/utils/build_script_helper.py
deleted file mode 100755
index e5b873f..0000000
--- a/benchmark/utils/build_script_helper.py
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/usr/bin/env python
-
-from __future__ import print_function
-
-import argparse
-import os
-import subprocess
-
-
-def main():
-    parser = argparse.ArgumentParser()
-    parser.add_argument('--verbose', '-v', action='store_true')
-    parser.add_argument('--package-path', type=str, required=True)
-    parser.add_argument('--build-path', type=str, required=True)
-    parser.add_argument('--toolchain', type=str, required=True)
-
-    # Build the debug/release versions.
-    args = parser.parse_args()
-    swiftbuild_path = os.path.join(args.toolchain, 'usr', 'bin', 'swift-build')
-    swiftbuild_args = [
-        swiftbuild_path,
-        '--package-path', args.package_path,
-        '--build-path', args.build_path,
-        '--configuration', 'debug',
-    ]
-    if args.verbose:
-        swiftbuild_args.append('--verbose')
-    subprocess.call(swiftbuild_args)
-
-    swiftbuild_args = [
-        swiftbuild_path,
-        '--package-path', args.package_path,
-        '--build-path', args.build_path,
-        '--configuration', 'release',
-        '-Xswiftc', '-Xllvm',
-        '-Xswiftc', '-align-module-to-page-size',
-    ]
-    if args.verbose:
-        swiftbuild_args.append('--verbose')
-    subprocess.call(swiftbuild_args)
-
-
-if __name__ == "__main__":
-    main()
diff --git a/utils/swift_build_support/swift_build_support/products/benchmarks.py b/utils/swift_build_support/swift_build_support/products/benchmarks.py
index 06ebdca..e62fe41 100644
--- a/utils/swift_build_support/swift_build_support/products/benchmarks.py
+++ b/utils/swift_build_support/swift_build_support/products/benchmarks.py
@@ -36,11 +36,11 @@
            .release.
         """
         cmdline = ['--num-iters=1', 'XorLoop']
-        debug_bench = os.path.join(self.build_dir, 'debug', 'SwiftBench')
-        shell.call([debug_bench] + cmdline)
+        bench_Onone = os.path.join(self.build_dir, 'bin', 'Benchmark_Onone')
+        shell.call([bench_Onone] + cmdline)
 
-        release_bench = os.path.join(self.build_dir, 'release', 'SwiftBench')
-        shell.call([release_bench] + cmdline)
+        bench_O = os.path.join(self.build_dir, 'bin', 'Benchmark_O')
+        shell.call([bench_O] + cmdline)
 
 
 def run_build_script_helper(host_target, product, args):
@@ -59,7 +59,8 @@
 
     # We use a separate python helper to enable quicker iteration when working
     # on this by avoiding going through build-script to test small changes.
-    helper_path = os.path.join(package_path, 'utils', 'build_script_helper.py')
+    helper_path = os.path.join(package_path, 'scripts',
+                               'build_script_helper.py')
 
     build_cmd = [
         helper_path,