Skip to content

Commit 157fbda

Browse files
committed
Merge remote-tracking branch 'upstream/sycl' into embed_fallback_svp
2 parents 230c8d9 + 814290d commit 157fbda

File tree

111 files changed

+1824
-326
lines changed

Some content is hidden

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

111 files changed

+1824
-326
lines changed

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,6 +1789,9 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn,
17891789
if (SyclOptReport.HasOptReportInfo(FD)) {
17901790
llvm::OptimizationRemarkEmitter ORE(Fn);
17911791
for (auto ORI : llvm::enumerate(SyclOptReport.GetInfo(FD))) {
1792+
// Temporarily apply arg location to ensure SourceLocToDebugLoc
1793+
// picks up the expected file.
1794+
ApplyDebugLocation TempApplyLoc(*this, ORI.value().KernelArgLoc);
17921795
llvm::DiagnosticLocation DL =
17931796
SourceLocToDebugLoc(ORI.value().KernelArgLoc);
17941797
StringRef NameInDesc = ORI.value().KernelArgDescName;

clang/lib/Driver/OffloadBundler.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -687,12 +687,12 @@ class ObjectFileHandler final : public FileHandler {
687687
if (Error Err = Symbol.printName(NameOS))
688688
return std::move(Err);
689689

690-
// If we are dealing with a bitcode file do not add special globals
691-
// llvm.used and llvm.compiler.used and __AsanDeviceGlobalMetadata to
690+
// If we are dealing with a bitcode file do not add special globals to
692691
// the list of defined symbols.
693692
if (SF->isIR() &&
694693
(Name == "llvm.used" || Name == "llvm.compiler.used" ||
695-
Name == "__AsanDeviceGlobalMetadata"))
694+
Name == "__AsanDeviceGlobalMetadata" ||
695+
Name == "__AsanKernelMetadata"))
696696
continue;
697697

698698
// Add symbol name with the target prefix to the buffer.

clang/lib/Driver/SanitizerArgs.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,9 @@ void SanitizerArgs::addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
11971197

11981198
CmdArgs.push_back("-mllvm");
11991199
CmdArgs.push_back("-asan-mapping-scale=4");
1200+
1201+
addSpecialCaseListOpt(Args, CmdArgs,
1202+
"-fsanitize-ignorelist=", UserIgnorelistFiles);
12001203
}
12011204
return;
12021205
}

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,23 @@ static std::vector<OptSpecifier> getUnsupportedOpts(void) {
16251625
return UnsupportedOpts;
16261626
}
16271627

1628+
// Currently supported options by SYCL NativeCPU device compilation
1629+
static inline bool SupportedByNativeCPU(const SYCLToolChain &TC,
1630+
const OptSpecifier &Opt) {
1631+
if (!TC.IsSYCLNativeCPU)
1632+
return false;
1633+
1634+
switch (Opt.getID()) {
1635+
case options::OPT_fcoverage_mapping:
1636+
case options::OPT_fno_coverage_mapping:
1637+
case options::OPT_fprofile_instr_generate:
1638+
case options::OPT_fprofile_instr_generate_EQ:
1639+
case options::OPT_fno_profile_instr_generate:
1640+
return true;
1641+
}
1642+
return false;
1643+
}
1644+
16281645
SYCLToolChain::SYCLToolChain(const Driver &D, const llvm::Triple &Triple,
16291646
const ToolChain &HostTC, const ArgList &Args)
16301647
: ToolChain(D, Triple, Args), HostTC(HostTC),
@@ -1636,6 +1653,9 @@ SYCLToolChain::SYCLToolChain(const Driver &D, const llvm::Triple &Triple,
16361653
// Diagnose unsupported options only once.
16371654
for (OptSpecifier Opt : getUnsupportedOpts()) {
16381655
if (const Arg *A = Args.getLastArg(Opt)) {
1656+
// Native CPU can support options unsupported by other targets.
1657+
if (SupportedByNativeCPU(*this, Opt))
1658+
continue;
16391659
// All sanitizer options are not currently supported, except
16401660
// AddressSanitizer
16411661
if (A->getOption().getID() == options::OPT_fsanitize_EQ &&
@@ -1676,6 +1696,9 @@ SYCLToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
16761696
bool Unsupported = false;
16771697
for (OptSpecifier UnsupportedOpt : getUnsupportedOpts()) {
16781698
if (Opt.matches(UnsupportedOpt)) {
1699+
// NativeCPU should allow most normal cpu options.
1700+
if (SupportedByNativeCPU(*this, Opt.getID()))
1701+
continue;
16791702
if (Opt.getID() == options::OPT_fsanitize_EQ &&
16801703
A->getValues().size() == 1) {
16811704
std::string SanitizeVal = A->getValue();

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3625,8 +3625,11 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
36253625
BodyStmts.insert(BodyStmts.end(), FinalizeStmts.begin(),
36263626
FinalizeStmts.end());
36273627

3628+
SourceLocation LL = NewBody ? NewBody->getBeginLoc() : SourceLocation();
3629+
SourceLocation LR = NewBody ? NewBody->getEndLoc() : SourceLocation();
3630+
36283631
return CompoundStmt::Create(SemaSYCLRef.getASTContext(), BodyStmts,
3629-
FPOptionsOverride(), {}, {});
3632+
FPOptionsOverride(), LL, LR);
36303633
}
36313634

36323635
void annotateHierarchicalParallelismAPICalls() {

clang/test/Driver/sycl-native-cpu.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,9 @@
2424

2525
// RUN: %clangxx -fsycl -fsycl-targets=spir64 %s -### 2>&1 | FileCheck -check-prefix=CHECK-NONATIVECPU %s
2626
// CHECK-NONATIVECPU-NOT: "-D" "__SYCL_NATIVE_CPU__"
27+
28+
// Checking that coverage testing options are accepted by native_cpu, and that device and host compilation invocations receive the same options
29+
// RUN: %clangxx -fsycl -fsycl-targets=native_cpu -Werror -fno-profile-instr-generate -fprofile-instr-generate -fno-coverage-mapping -fcoverage-mapping -### %s 2>&1 | FileCheck %s --check-prefix=CHECK_COV_INVO
30+
// CHECK_COV_INVO:{{.*}}clang{{.*}}-fsycl-is-device{{.*}}"-fsycl-is-native-cpu" "-D" "__SYCL_NATIVE_CPU__"{{.*}}"-fprofile-instrument=clang"{{.*}}"-fcoverage-mapping" "-fcoverage-compilation-dir={{.*}}"
31+
// CHECK_COV_INVO:{{.*}}clang{{.*}}"-fsycl-is-host"{{.*}}"-fprofile-instrument=clang"{{.*}}"-fcoverage-mapping" "-fcoverage-compilation-dir={{.*}}"
32+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %clang_cc1 -fsycl-is-device -ast-dump %s | FileCheck %s
2+
//
3+
// Checks that the compound statement of the implicitly generated kernel body
4+
// has a valid source location (containing "line"). Previously this location
5+
// was invalid containing "<<invalid sloc>>" which causes asserts in the
6+
// llvm profiling tools.
7+
8+
#include "Inputs/sycl.hpp"
9+
10+
struct Functor {
11+
void operator()() const {}
12+
};
13+
14+
// CHECK: FunctionDecl {{.*}} _ZTS7Functor 'void ()'
15+
// CHECK-NEXT: |-CompoundStmt {{.*}} <{{.*}}line{{.*}}>
16+
17+
int main() {
18+
19+
sycl::queue().submit([&](sycl::handler &cgh) {
20+
cgh.single_task(Functor{});
21+
});
22+
}

devops/dependencies-igc-dev.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"linux": {
33
"igc_dev": {
4-
"github_tag": "igc-dev-7dad678",
5-
"version": "7dad678",
6-
"updated_at": "2024-11-24T10:48:51Z",
7-
"url": "https://api.github.com/repos/intel/intel-graphics-compiler/actions/artifacts/2229466354/zip",
4+
"github_tag": "igc-dev-6ee988a",
5+
"version": "6ee988a",
6+
"updated_at": "2024-11-26T15:44:10Z",
7+
"url": "https://api.github.com/repos/intel/intel-graphics-compiler/actions/artifacts/2239640503/zip",
88
"root": "{DEPS_ROOT}/opencl/runtime/linux/oclgpu"
99
}
1010
}

libdevice/sanitizer/asan_rtl.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,11 +665,16 @@ constexpr size_t AlignMask(size_t n) { return n - 1; }
665665
///
666666
/// ASAN Load/Store Report Built-ins
667667
///
668+
/// NOTE:
669+
/// if __AsanLaunchInfo equals 0, the sanitizer is disabled for this launch
670+
///
668671

669672
#define ASAN_REPORT_ERROR_BASE(type, is_write, size, as) \
670673
DEVICE_EXTERN_C_NOINLINE void __asan_##type##size##_as##as( \
671674
uptr addr, const char __SYCL_CONSTANT__ *file, uint32_t line, \
672675
const char __SYCL_CONSTANT__ *func) { \
676+
if (!__AsanLaunchInfo) \
677+
return; \
673678
if (addr & AlignMask(size)) { \
674679
__asan_report_misalign_error(addr, as, size, is_write, addr, file, line, \
675680
func); \
@@ -682,6 +687,8 @@ constexpr size_t AlignMask(size_t n) { return n - 1; }
682687
DEVICE_EXTERN_C_NOINLINE void __asan_##type##size##_as##as##_noabort( \
683688
uptr addr, const char __SYCL_CONSTANT__ *file, uint32_t line, \
684689
const char __SYCL_CONSTANT__ *func) { \
690+
if (!__AsanLaunchInfo) \
691+
return; \
685692
if (addr & AlignMask(size)) { \
686693
__asan_report_misalign_error(addr, as, size, is_write, addr, file, line, \
687694
func, true); \
@@ -714,6 +721,8 @@ ASAN_REPORT_ERROR(store, true, 16)
714721
DEVICE_EXTERN_C_NOINLINE void __asan_##type##N_as##as( \
715722
uptr addr, size_t size, const char __SYCL_CONSTANT__ *file, \
716723
uint32_t line, const char __SYCL_CONSTANT__ *func) { \
724+
if (!__AsanLaunchInfo) \
725+
return; \
717726
if (auto poisoned_addr = __asan_region_is_poisoned(addr, as, size)) { \
718727
__asan_report_access_error(addr, as, size, is_write, poisoned_addr, \
719728
file, line, func); \
@@ -722,6 +731,8 @@ ASAN_REPORT_ERROR(store, true, 16)
722731
DEVICE_EXTERN_C_NOINLINE void __asan_##type##N_as##as##_noabort( \
723732
uptr addr, size_t size, const char __SYCL_CONSTANT__ *file, \
724733
uint32_t line, const char __SYCL_CONSTANT__ *func) { \
734+
if (!__AsanLaunchInfo) \
735+
return; \
725736
if (auto poisoned_addr = __asan_region_is_poisoned(addr, as, size)) { \
726737
__asan_report_access_error(addr, as, size, is_write, poisoned_addr, \
727738
file, line, func, true); \
@@ -743,6 +754,9 @@ ASAN_REPORT_ERROR_N(store, true)
743754
///
744755

745756
DEVICE_EXTERN_C_NOINLINE uptr __asan_mem_to_shadow(uptr ptr, uint32_t as) {
757+
if (!__AsanLaunchInfo)
758+
return 0;
759+
746760
return MemToShadow(ptr, as);
747761
}
748762

@@ -756,6 +770,9 @@ static __SYCL_CONSTANT__ const char __mem_set_shadow_local[] =
756770
DEVICE_EXTERN_C_NOINLINE void
757771
__asan_set_shadow_static_local(uptr ptr, size_t size,
758772
size_t size_with_redzone) {
773+
if (!__AsanLaunchInfo)
774+
return;
775+
759776
// Since ptr is aligned to ASAN_SHADOW_GRANULARITY,
760777
// if size != aligned_size, then the buffer tail of ptr is not aligned
761778
uptr aligned_size = RoundUpTo(size, ASAN_SHADOW_GRANULARITY);
@@ -795,6 +812,9 @@ static __SYCL_CONSTANT__ const char __mem_unpoison_shadow_static_local_end[] =
795812
DEVICE_EXTERN_C_NOINLINE void
796813
__asan_unpoison_shadow_static_local(uptr ptr, size_t size,
797814
size_t size_with_redzone) {
815+
if (!__AsanLaunchInfo)
816+
return;
817+
798818
ASAN_DEBUG(__spirv_ocl_printf(__mem_unpoison_shadow_static_local_begin));
799819

800820
auto shadow_begin = MemToShadow(ptr + size, ADDRESS_SPACE_LOCAL);
@@ -828,6 +848,9 @@ static __SYCL_CONSTANT__ const char __mem_report_arg_count_incorrect[] =
828848

829849
DEVICE_EXTERN_C_NOINLINE void
830850
__asan_set_shadow_dynamic_local(uptr ptr, uint32_t num_args) {
851+
if (!__AsanLaunchInfo)
852+
return;
853+
831854
ASAN_DEBUG(__spirv_ocl_printf(__mem_set_shadow_dynamic_local_begin));
832855

833856
auto *launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
@@ -859,6 +882,9 @@ static __SYCL_CONSTANT__ const char __mem_unpoison_shadow_dynamic_local_end[] =
859882

860883
DEVICE_EXTERN_C_NOINLINE void
861884
__asan_unpoison_shadow_dynamic_local(uptr ptr, uint32_t num_args) {
885+
if (!__AsanLaunchInfo)
886+
return;
887+
862888
ASAN_DEBUG(__spirv_ocl_printf(__mem_unpoison_shadow_dynamic_local_begin));
863889

864890
auto *launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
@@ -895,6 +921,9 @@ static __SYCL_CONSTANT__ const char __mem_set_shadow_private[] =
895921

896922
DEVICE_EXTERN_C_NOINLINE void __asan_set_shadow_private(uptr begin, uptr size,
897923
char val) {
924+
if (!__AsanLaunchInfo)
925+
return;
926+
898927
ASAN_DEBUG(__spirv_ocl_printf(__mem_set_shadow_private_begin));
899928

900929
auto *launch_info = (__SYCL_GLOBAL__ const LaunchInfo *)__AsanLaunchInfo;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===-- AsanKernelMetadata.h - fix kernel medatadata for sanitizer ---===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
// This pass fixes attributes and metadata of the global variable
9+
// "__AsanKernelMetadata"
10+
//===----------------------------------------------------------------------===//
11+
12+
#pragma once
13+
14+
#include "llvm/IR/PassManager.h"
15+
16+
namespace llvm {
17+
18+
class AsanKernelMetadataPass : public PassInfoMixin<AsanKernelMetadataPass> {
19+
public:
20+
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
21+
};
22+
23+
} // namespace llvm

0 commit comments

Comments
 (0)