Skip to content

Commit 06b1fad

Browse files
committed
Merge branch 'arch-lit' of github.com:mateuszpn/llvm into arch-lit
2 parents a1f5651 + 8e2f046 commit 06b1fad

File tree

42 files changed

+475
-260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+475
-260
lines changed

.github/workflows/sycl-linux-build.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,6 @@ jobs:
339339
sycl_compiler: $GITHUB_WORKSPACE/toolchain/bin/clang++
340340
extra_lit_opts: --param sycl_build_targets="spir;nvidia;amd"
341341

342-
- name: Remove E2E tests before spirv-backend run
343-
if: ${{ inputs.e2e_binaries_spirv_backend_artifact && !cancelled() && steps.build.conclusion == 'success' }}
344-
run: rm -rf build-e2e
345-
346342
- name: Build E2E tests with SPIR-V Backend
347343
if: ${{ inputs.e2e_binaries_spirv_backend_artifact && !cancelled() && steps.build.conclusion == 'success' }}
348344
uses: ./devops/actions/run-tests/e2e
@@ -354,10 +350,6 @@ jobs:
354350
sycl_compiler: $GITHUB_WORKSPACE/toolchain/bin/clang++
355351
extra_lit_opts: --param spirv-backend=True
356352

357-
- name: Remove E2E tests before preview-mode run
358-
if: ${{ inputs.e2e_binaries_preview_artifact && !cancelled() && steps.build.conclusion == 'success' }}
359-
run: rm -rf build-e2e
360-
361353
- name: Build E2E tests in Preview Mode
362354
if: ${{ inputs.e2e_binaries_preview_artifact && !cancelled() && steps.build.conclusion == 'success' }}
363355
uses: ./devops/actions/run-tests/e2e

buildbot/compile.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,18 @@ def do_compile(args):
3131
"cmake",
3232
"--build",
3333
abs_obj_dir,
34+
]
35+
36+
if args.verbose:
37+
cmake_cmd.append("--verbose")
38+
39+
cmake_cmd += [
3440
"--",
3541
args.build_target,
3642
"-j",
3743
str(cpu_count),
3844
]
3945

40-
if args.verbose:
41-
cmake_cmd.append("--verbose")
42-
4346
print("[Cmake Command]: {}".format(" ".join(cmake_cmd)))
4447

4548
subprocess.check_call(cmake_cmd, cwd=abs_obj_dir)

buildbot/configure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def do_configure(args, passthrough_args):
2121
if not os.path.isdir(abs_obj_dir):
2222
os.makedirs(abs_obj_dir)
2323

24-
llvm_external_projects = "sycl;llvm-spirv;opencl;xpti;xptifw"
24+
llvm_external_projects = "sycl;llvm-spirv;opencl;xpti;xptifw;compiler-rt"
2525

2626
# libdevice build requires a working SYCL toolchain, which is not the case
2727
# with macOS target right now.

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,9 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
12131213
PB.registerPipelineStartEPCallback(
12141214
[Options](ModulePassManager &MPM, OptimizationLevel Level) {
12151215
MPM.addPass(InstrProfilingLoweringPass(*Options, false));
1216+
// The profiling pass adds SYCL device globals so we need to run
1217+
// the compile-time properties pass to update the metadata.
1218+
MPM.addPass(CompileTimePropertiesPass());
12161219
});
12171220

12181221
// TODO: Consider passing the MemoryProfileOutput to the pass builder via

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5423,6 +5423,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
54235423
CmdArgs.push_back("-fsycl-is-device");
54245424
CmdArgs.push_back("-fdeclare-spirv-builtins");
54255425

5426+
// Set the atomic profile update flag to increment counters atomically.
5427+
CmdArgs.push_back("-fprofile-update=atomic");
5428+
54265429
// Set O2 optimization level by default
54275430
if (!Args.getLastArg(options::OPT_O_Group))
54285431
CmdArgs.push_back("-O2");

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,11 +1371,7 @@ static ArrayRef<options::ID> getUnsupportedOpts() {
13711371
options::OPT_fno_profile_generate, // -f[no-]profile-generate
13721372
options::OPT_ftest_coverage,
13731373
options::OPT_fno_test_coverage, // -f[no-]test-coverage
1374-
options::OPT_fcoverage_mapping,
1375-
options::OPT_coverage, // --coverage
1376-
options::OPT_fno_coverage_mapping, // -f[no-]coverage-mapping
1377-
options::OPT_fprofile_instr_generate,
1378-
options::OPT_fprofile_instr_generate_EQ,
1374+
options::OPT_coverage, // --coverage
13791375
options::OPT_fprofile_arcs,
13801376
options::OPT_fno_profile_arcs, // -f[no-]profile-arcs
13811377
options::OPT_fno_profile_instr_generate, // -f[no-]profile-instr-generate
Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
/// Test that SYCL bitcode device libraries are properly separated for NVIDIA and AMD targets.
22

3-
/// Check devicelib and libspirv are linked for nvptx.
3+
/// Check devicelib are linked for nvptx.
44
// RUN: %clang -### -fsycl --offload-new-driver \
5+
// RUN: -fno-sycl-libspirv -Wno-unsafe-libspirv-not-linked \
56
// RUN: -fsycl-targets=nvptx64-nvidia-cuda \
67
// RUN: --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
78
// RUN: %s 2>&1 | FileCheck -check-prefix=CHECK-NVPTX-BC %s
89

910
// RUN: %clang_cl -### -fsycl --offload-new-driver \
11+
// RUN: -fno-sycl-libspirv -Wno-unsafe-libspirv-not-linked \
1012
// RUN: -fsycl-targets=nvptx64-nvidia-cuda \
1113
// RUN: --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
1214
// RUN: %s 2>&1 | FileCheck -check-prefix=CHECK-NVPTX-BC %s
1315

1416
// CHECK-NVPTX-BC: clang-linker-wrapper
15-
// CHECK-NVPTX-BC-SAME: "--bitcode-library=nvptx64-nvidia-cuda={{.*}}devicelib-nvptx64-nvidia-cuda.bc" "--bitcode-library=nvptx64-nvidia-cuda={{.*}}libspirv-nvptx64-nvidia-cuda.bc"
17+
// CHECK-NVPTX-BC-SAME: "--bitcode-library=nvptx64-nvidia-cuda={{.*}}devicelib-nvptx64-nvidia-cuda.bc"
1618

1719
/// Check devicelib is linked for amdgcn.
1820
// RUN: %clang -### -fsycl --offload-new-driver \
21+
// RUN: -fno-sycl-libspirv -Wno-unsafe-libspirv-not-linked \
1922
// RUN: -fsycl-targets=amdgcn-amd-amdhsa \
2023
// RUN: -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx900 \
2124
// RUN: --rocm-path=%S/Inputs/rocm \
2225
// RUN: %s 2>&1 | FileCheck -check-prefix=CHECK-AMD-BC %s
2326

2427
// RUN: %clang_cl -### -fsycl --offload-new-driver \
28+
// RUN: -fno-sycl-libspirv -Wno-unsafe-libspirv-not-linked \
2529
// RUN: -fsycl-targets=amdgcn-amd-amdhsa \
2630
// RUN: -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx900 \
2731
// RUN: --rocm-path=%S/Inputs/rocm \
@@ -32,35 +36,42 @@
3236

3337
/// Check linking with multiple targets.
3438
// RUN: %clang -### -fsycl --offload-new-driver \
39+
// RUN: -fno-sycl-libspirv -Wno-unsafe-libspirv-not-linked \
3540
// RUN: -fsycl-targets=amdgcn-amd-amdhsa,nvptx64-nvidia-cuda \
3641
// RUN: -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx900 \
3742
// RUN: --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
3843
// RUN: --rocm-path=%S/Inputs/rocm \
3944
// RUN: %s 2>&1 | FileCheck -check-prefix=CHECK-MULTI-TARGET %s
4045

4146
// RUN: %clang_cl -### -fsycl --offload-new-driver \
47+
// RUN: -fno-sycl-libspirv -Wno-unsafe-libspirv-not-linked \
4248
// RUN: -fsycl-targets=amdgcn-amd-amdhsa,nvptx64-nvidia-cuda \
4349
// RUN: -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx900 \
4450
// RUN: --cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
4551
// RUN: --rocm-path=%S/Inputs/rocm \
4652
// RUN: %s 2>&1 | FileCheck -check-prefix=CHECK-MULTI-TARGET %s
4753

4854
// CHECK-MULTI-TARGET: clang-linker-wrapper
49-
// CHECK-MULTI-TARGET-SAME: "--bitcode-library=amdgcn-amd-amdhsa={{.*}}devicelib-amdgcn-amd-amdhsa.bc" "--bitcode-library=nvptx64-nvidia-cuda={{.*}}devicelib-nvptx64-nvidia-cuda.bc" "--bitcode-library=nvptx64-nvidia-cuda={{.*}}libspirv-nvptx64-nvidia-cuda.bc"
55+
// CHECK-MULTI-TARGET-SAME: "--bitcode-library=amdgcn-amd-amdhsa={{.*}}devicelib-amdgcn-amd-amdhsa.bc" "--bitcode-library=nvptx64-nvidia-cuda={{.*}}devicelib-nvptx64-nvidia-cuda.bc"
5056

5157
/// Test --bitcode-library with nvptx dummy libraries.
5258
// RUN: %clang -cc1 %s -triple nvptx64-nvidia-cuda -emit-llvm-bc -o %t.nvptx.devicelib.bc
53-
// RUN: %clang -cc1 %s -triple nvptx64-nvidia-cuda -emit-llvm-bc -o %t.nvptx.libspirv.bc
54-
// RUN: %clangxx -fsycl -fsycl-targets=nvptx64-nvidia-cuda --offload-new-driver -c %s -o %t.nvptx.o -nocudalib
55-
// RUN: clang-linker-wrapper --bitcode-library=nvptx64-nvidia-cuda=%t.nvptx.devicelib.bc --bitcode-library=nvptx64-nvidia-cuda=%t.nvptx.libspirv.bc \
59+
// RUN: %clang -cc1 %s -triple nvptx64-nvidia-cuda -emit-llvm-bc -o %t.nvptx.libdummy.bc
60+
// RUN: %clangxx -fsycl -fsycl-targets=nvptx64-nvidia-cuda \
61+
// RUN: -fno-sycl-libspirv -Wno-unsafe-libspirv-not-linked \
62+
// RUN: --offload-new-driver -c %s -o %t.nvptx.o -nocudalib
63+
// RUN: clang-linker-wrapper --bitcode-library=nvptx64-nvidia-cuda=%t.nvptx.devicelib.bc --bitcode-library=nvptx64-nvidia-cuda=%t.nvptx.libdummy.bc \
5664
// RUN: --host-triple=x86_64-unknown-linux-gnu --dry-run \
5765
// RUN: --linker-path=/usr/bin/ld %t.nvptx.o -o a.out 2>&1 | FileCheck -check-prefix=CHECK-WRAPPER-NVPTX %s
5866

59-
// CHECK-WRAPPER-NVPTX: llvm-link{{.*}} {{.*}}.nvptx.devicelib.bc {{.*}}.nvptx.libspirv.bc
67+
// CHECK-WRAPPER-NVPTX: llvm-link{{.*}} {{.*}}.nvptx.devicelib.bc {{.*}}.nvptx.libdummy.bc
6068

6169
/// Test --bitcode-library with amdgcn dummy library.
6270
// RUN: %clang -cc1 %s -triple amdgcn-amd-amdhsa -emit-llvm-bc -o %t.amd.devicelib.bc
63-
// RUN: %clangxx -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx900 --offload-new-driver -c %s -o %t.amd.o -nogpulib
71+
// RUN: %clangxx -fsycl -fsycl-targets=amdgcn-amd-amdhsa \
72+
// RUN: -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx900 \
73+
// RUN: -fno-sycl-libspirv -Wno-unsafe-libspirv-not-linked \
74+
// RUN: --offload-new-driver -c %s -o %t.amd.o -nogpulib -fgpu-rdc
6475
// RUN: clang-linker-wrapper --bitcode-library=amdgcn-amd-amdhsa=%t.amd.devicelib.bc \
6576
// RUN: --host-triple=x86_64-unknown-linux-gnu --dry-run \
6677
// RUN: --linker-path=/usr/bin/ld %t.amd.o -o a.out 2>&1 | FileCheck -check-prefix=CHECK-WRAPPER-AMD %s
@@ -70,10 +81,11 @@
7081
/// Test --bitcode-library with multi-target bc libraries.
7182
// RUN: %clangxx -fsycl -fsycl-targets=amdgcn-amd-amdhsa,nvptx64-nvidia-cuda \
7283
// RUN: -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx900 \
73-
// RUN: --offload-new-driver -c %s -o %t.multi.o -nocudalib -nogpulib
74-
// RUN: clang-linker-wrapper --bitcode-library=amdgcn-amd-amdhsa=%t.amd.devicelib.bc --bitcode-library=nvptx64-nvidia-cuda=%t.nvptx.devicelib.bc --bitcode-library=nvptx64-nvidia-cuda=%t.nvptx.libspirv.bc \
84+
// RUN: -fno-sycl-libspirv -Wno-unsafe-libspirv-not-linked \
85+
// RUN: --offload-new-driver -c %s -o %t.multi.o -nocudalib -nogpulib -fgpu-rdc
86+
// RUN: clang-linker-wrapper --bitcode-library=amdgcn-amd-amdhsa=%t.amd.devicelib.bc --bitcode-library=nvptx64-nvidia-cuda=%t.nvptx.devicelib.bc --bitcode-library=nvptx64-nvidia-cuda=%t.nvptx.libdummy.bc \
7587
// RUN: --host-triple=x86_64-unknown-linux-gnu --dry-run \
7688
// RUN: --linker-path=/usr/bin/ld %t.multi.o -o a.out 2>&1 | FileCheck -check-prefix=CHECK-WRAPPER-MULTI %s
7789

7890
// CHECK-WRAPPER-MULTI: llvm-link{{.*}} {{.*}}.amd.devicelib.bc
79-
// CHECK-WRAPPER-MULTI: llvm-link{{.*}} {{.*}}.nvptx.devicelib.bc {{.*}}.nvptx.libspirv.bc
91+
// CHECK-WRAPPER-MULTI: llvm-link{{.*}} {{.*}}.nvptx.devicelib.bc {{.*}}.nvptx.libdummy.bc
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Ensure that the profile update mode is set to 'atomic' when compiling SYCL code.
2+
// RUN: %clangxx -### -fsycl -fprofile-instr-generate -fcoverage-mapping %s 2>&1 | FileCheck %s
3+
// RUN: %clang_cl -### -fsycl -fprofile-instr-generate -fcoverage-mapping %s 2>&1 | FileCheck %s
4+
// CHECK: "-fprofile-update=atomic"

clang/test/Driver/sycl-unsupported.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@
1919
// RUN: -DOPT_CC1=-debug-info-kind=line-tables-only \
2020
// RUN: -check-prefixes=UNSUPPORTED_OPT_DIAG,UNSUPPORTED_OPT
2121

22-
// RUN: %clangxx -fsycl -fprofile-instr-generate -### %s 2>&1 \
23-
// RUN: | FileCheck %s -DARCH=spir64 -DOPT=-fprofile-instr-generate \
24-
// RUN: -DOPT_CC1=-fprofile-instrument=clang \
25-
// RUN: -check-prefixes=UNSUPPORTED_OPT_DIAG,UNSUPPORTED_OPT
26-
// RUN: %clangxx -fsycl -fcoverage-mapping \
27-
// RUN: -fprofile-instr-generate -### %s 2>&1 \
28-
// RUN: | FileCheck %s -DARCH=spir64 -DOPT=-fcoverage-mapping
2922
// RUN: %clangxx -fsycl -ftest-coverage -### %s 2>&1 \
3023
// RUN: | FileCheck %s -DARCH=spir64 -DOPT=-ftest-coverage \
3124
// RUN: -DOPT_CC1=-coverage-notes-file \
@@ -49,12 +42,6 @@
4942
// RUN: | FileCheck %s -DARCH=spir64 -DOPT=--coverage \
5043
// RUN: -DOPT_CC1=-coverage-notes-file \
5144
// RUN: -check-prefixes=UNSUPPORTED_OPT_DIAG,UNSUPPORTED_OPT
52-
// Check to make sure our '-fsanitize=address' exception isn't triggered by a
53-
// different option
54-
// RUN: %clangxx -fsycl -fprofile-instr-generate=address -### %s 2>&1 \
55-
// RUN: | FileCheck %s -DARCH=spir64 -DOPT=-fprofile-instr-generate=address \
56-
// RUN: -DOPT_CC1=-fprofile-instrument=clang \
57-
// RUN: -check-prefixes=UNSUPPORTED_OPT_DIAG,UNSUPPORTED_OPT
5845

5946
// CHECK: ignoring '[[OPT]]' option as it is not currently supported for target '[[ARCH]]{{.*}}'; only supported for host compilation [-Woption-ignored]
6047
// CHECK-NOT: clang{{.*}} "-fsycl-is-device"{{.*}} "[[OPT]]{{.*}}"

compiler-rt/lib/profile/InstrProfilingRuntime.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@ extern "C" {
1010

1111
#include "InstrProfiling.h"
1212

13+
void __sycl_increment_profile_counters(uint64_t FnHash, size_t NumCounters,
14+
const uint64_t *Increments) {
15+
for (const __llvm_profile_data *DataVar = __llvm_profile_begin_data();
16+
DataVar < __llvm_profile_end_data(); DataVar++) {
17+
if (DataVar->NameRef != FnHash || DataVar->NumCounters != NumCounters)
18+
continue;
19+
20+
uint64_t *const Counters = reinterpret_cast<uint64_t *>(
21+
reinterpret_cast<uintptr_t>(DataVar) +
22+
reinterpret_cast<uintptr_t>(DataVar->CounterPtr));
23+
for (size_t i = 0; i < NumCounters; i++)
24+
Counters[i] += Increments[i];
25+
break;
26+
}
27+
}
28+
1329
static int RegisterRuntime() {
1430
__llvm_profile_initialize();
1531
#ifdef _AIX

0 commit comments

Comments
 (0)