Skip to content

Commit c4e2206

Browse files
Merge branch 'sycl' into programbuildrefactor
2 parents 2b4d903 + 8bb4115 commit c4e2206

File tree

314 files changed

+3098
-3489
lines changed

Some content is hidden

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

314 files changed

+3098
-3489
lines changed

.github/CODEOWNERS

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,12 @@ sycl/test-e2e/LLVMIntrinsicLowering/ @intel/dpcpp-spirv-reviewers
169169

170170
# Sanitizer
171171
clang/lib/Driver/SanitizerArgs.cpp @intel/dpcpp-sanitizers-review
172-
libdevice/sanitizer_utils.cpp @intel/dpcpp-sanitizers-review
173-
libdevice/include/asan_libdevice.hpp @intel/dpcpp-sanitizers-review
174-
libdevice/include/sanitizer_utils.hpp @intel/dpcpp-sanitizers-review
172+
libdevice/include/asan_rtl.hpp @intel/dpcpp-sanitizers-review
173+
libdevice/include/sanitizer_defs.hpp @intel/dpcpp-sanitizers-review
174+
libdevice/sanitizer/ @intel/dpcpp-sanitizers-review
175+
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h @intel/dpcpp-sanitizers-review
176+
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h @intel/dpcpp-sanitizers-review
177+
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h @intel/dpcpp-sanitizers-review
175178
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @intel/dpcpp-sanitizers-review
176-
sycl/test-e2e/AddressSanitizer/ @intel/dpcpp-sanitizers-review
177179
llvm/test/Instrumentation/AddressSanitizer/ @intel/dpcpp-sanitizers-review
178-
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerOptions.h @intel/dpcpp-sanitizers-review
179-
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h @intel/dpcpp-sanitizers-review
180-
llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h @intel/dpcpp-sanitizers-review
180+
sycl/test-e2e/AddressSanitizer/ @intel/dpcpp-sanitizers-review

clang/lib/CodeGen/CodeGenTypes.cpp

Lines changed: 1 addition & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -350,34 +350,6 @@ llvm::Type *CodeGenTypes::ConvertFunctionTypeInternal(QualType QFT) {
350350
return ResultType;
351351
}
352352

353-
template <bool NeedTypeInterpret = false>
354-
llvm::Type *getJointMatrixINTELExtType(llvm::Type *CompTy,
355-
ArrayRef<TemplateArgument> TemplateArgs,
356-
const unsigned Val = 0) {
357-
// TODO: we should actually have exactly 5 template parameters: 1 for
358-
// type and 4 for type parameters. But in previous version of the SPIR-V
359-
// spec we have Layout matrix type parameter, that was later removed.
360-
// Once we update to the newest version of the spec - this should be updated.
361-
assert((TemplateArgs.size() == 5 || TemplateArgs.size() == 6) &&
362-
"Wrong JointMatrixINTEL template parameters number");
363-
// This is required to represent optional 'Component Type Interpretation'
364-
// parameter
365-
std::vector<unsigned> Params;
366-
for (size_t I = 1; I != TemplateArgs.size(); ++I) {
367-
assert(TemplateArgs[I].getKind() == TemplateArgument::Integral &&
368-
"Wrong JointMatrixINTEL template parameter");
369-
Params.push_back(TemplateArgs[I].getAsIntegral().getExtValue());
370-
}
371-
// Don't add type interpretation for legacy matrices.
372-
// Legacy matrices has 5 template parameters, while new representation
373-
// has 6.
374-
if (NeedTypeInterpret && TemplateArgs.size() != 5)
375-
Params.push_back(Val);
376-
377-
return llvm::TargetExtType::get(CompTy->getContext(),
378-
"spirv.JointMatrixINTEL", {CompTy}, Params);
379-
}
380-
381353
llvm::Type *
382354
getCooperativeMatrixKHRExtType(llvm::Type *CompTy,
383355
ArrayRef<TemplateArgument> TemplateArgs) {
@@ -394,49 +366,6 @@ getCooperativeMatrixKHRExtType(llvm::Type *CompTy,
394366
CompTy->getContext(), "spirv.CooperativeMatrixKHR", {CompTy}, Params);
395367
}
396368

397-
/// ConvertSYCLJointMatrixINTELType - Convert SYCL joint_matrix type
398-
/// which is represented as a pointer to a structure to LLVM extension type
399-
/// with the parameters that follow SPIR-V JointMatrixINTEL type.
400-
/// The expected representation is:
401-
/// target("spirv.JointMatrixINTEL", %element_type, %rows%, %cols%, %scope%,
402-
/// %use%, (optional) %element_type_interpretation%)
403-
llvm::Type *CodeGenTypes::ConvertSYCLJointMatrixINTELType(RecordDecl *RD) {
404-
auto *TemplateDecl = cast<ClassTemplateSpecializationDecl>(RD);
405-
ArrayRef<TemplateArgument> TemplateArgs =
406-
TemplateDecl->getTemplateArgs().asArray();
407-
assert(TemplateArgs[0].getKind() == TemplateArgument::Type &&
408-
"1st JointMatrixINTEL template parameter must be type");
409-
llvm::Type *CompTy = ConvertType(TemplateArgs[0].getAsType());
410-
411-
// Per JointMatrixINTEL spec the type can have an optional
412-
// 'Component Type Interpretation' parameter. We should emit it in case
413-
// if on SYCL level joint matrix accepts 'bfloat16' or 'tf32' objects as
414-
// matrix's components. Yet 'bfloat16' should be represented as 'int16' and
415-
// 'tf32' as 'float' types.
416-
if (CompTy->isStructTy()) {
417-
StringRef LlvmTyName = CompTy->getStructName();
418-
// Emit half/int16/float for sycl[::*]::{half,bfloat16,tf32}
419-
if (LlvmTyName.starts_with("class.sycl::") ||
420-
LlvmTyName.starts_with("class.__sycl_internal::"))
421-
LlvmTyName = LlvmTyName.rsplit("::").second;
422-
if (LlvmTyName == "half") {
423-
CompTy = llvm::Type::getHalfTy(getLLVMContext());
424-
return getJointMatrixINTELExtType(CompTy, TemplateArgs);
425-
} else if (LlvmTyName == "tf32") {
426-
CompTy = llvm::Type::getFloatTy(getLLVMContext());
427-
// 'tf32' interpretation is mapped to '0'
428-
return getJointMatrixINTELExtType<true>(CompTy, TemplateArgs, 0);
429-
} else if (LlvmTyName == "bfloat16") {
430-
CompTy = llvm::Type::getInt16Ty(getLLVMContext());
431-
// 'bfloat16' interpretation is mapped to '1'
432-
return getJointMatrixINTELExtType<true>(CompTy, TemplateArgs, 1);
433-
} else {
434-
llvm_unreachable("Wrong matrix base type!");
435-
}
436-
}
437-
return getJointMatrixINTELExtType(CompTy, TemplateArgs);
438-
}
439-
440369
/// ConvertSPVCooperativeMatrixType - Convert SYCL joint_matrix type
441370
/// which is represented as a pointer to a structure to LLVM extension type
442371
/// with the parameters that follow SPIR-V CooperativeMatrixKHR type.
@@ -733,11 +662,7 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
733662
if (ClangETy && ClangETy->isStructureOrClassType()) {
734663
RecordDecl *RD = ClangETy->getAsCXXRecordDecl();
735664
if (RD && RD->getQualifiedNameAsString() ==
736-
"__spv::__spirv_JointMatrixINTEL") {
737-
ResultType = ConvertSYCLJointMatrixINTELType(RD);
738-
break;
739-
} else if (RD && RD->getQualifiedNameAsString() ==
740-
"__spv::__spirv_CooperativeMatrixKHR") {
665+
"__spv::__spirv_CooperativeMatrixKHR") {
741666
ResultType = ConvertSPVCooperativeMatrixType(RD);
742667
break;
743668
} else if (RD && RD->getQualifiedNameAsString() ==

clang/lib/CodeGen/CodeGenTypes.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,6 @@ class CodeGenTypes {
145145
/// load/store type are the same.
146146
llvm::Type *convertTypeForLoadStore(QualType T, llvm::Type *LLVMTy = nullptr);
147147

148-
/// ConvertSYCLJointMatrixINTELType - Convert SYCL joint_matrix type
149-
/// which is represented as a pointer to a structure to LLVM extension type
150-
/// with the parameters that follow SPIR-V JointMatrixINTEL type.
151-
/// The expected representation is:
152-
/// target("spirv.JointMatrixINTEL", %element_type, %rows%, %cols%, %scope%,
153-
/// %use%, (optional) %element_type_interpretation%)
154-
llvm::Type *ConvertSYCLJointMatrixINTELType(RecordDecl *RD);
155-
156148
/// ConvertSPVCooperativeMatrixType - Convert SYCL joint_matrix type
157149
/// which is represented as a pointer to a structure to LLVM extension type
158150
/// with the parameters that follow SPIR-V CooperativeMatrixKHR type.

clang/lib/Driver/OffloadBundler.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,11 @@ class ObjectFileHandler final : public FileHandler {
688688
return std::move(Err);
689689

690690
// If we are dealing with a bitcode file do not add special globals
691-
// llvm.used and llvm.compiler.used to the list of defined symbols.
692-
if (SF->isIR() && (Name == "llvm.used" || Name == "llvm.compiler.used"))
691+
// llvm.used and llvm.compiler.used and __AsanDeviceGlobalMetadata to
692+
// the list of defined symbols.
693+
if (SF->isIR() &&
694+
(Name == "llvm.used" || Name == "llvm.compiler.used" ||
695+
Name == "__AsanDeviceGlobalMetadata"))
693696
continue;
694697

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

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10674,12 +10674,8 @@ static void getTripleBasedSPIRVTransOpts(Compilation &C,
1067410674
ArgStringList &TranslatorArgs) {
1067510675
bool IsCPU = Triple.isSPIR() &&
1067610676
Triple.getSubArch() == llvm::Triple::SPIRSubArch_x86_64;
10677-
// Enable NonSemanticShaderDebugInfo.200 for CPU AOT and for non-Windows
10678-
const bool IsWindowsMSVC =
10679-
Triple.isWindowsMSVCEnvironment() ||
10680-
C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment();
10681-
const bool EnableNonSemanticDebug =
10682-
IsCPU || (!IsWindowsMSVC && !C.getDriver().IsFPGAHWMode());
10677+
// Enable NonSemanticShaderDebugInfo.200 for non-FPGA targets.
10678+
const bool EnableNonSemanticDebug = !C.getDriver().IsFPGAHWMode();
1068310679
if (EnableNonSemanticDebug) {
1068410680
TranslatorArgs.push_back(
1068510681
"-spirv-debug-info-version=nonsemantic-shader-200");

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -658,43 +658,44 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
658658
addLibraries(SYCLDeviceAnnotationLibs);
659659

660660
#if !defined(_WIN32)
661+
std::string SanitizeVal;
661662
size_t sanitizer_lib_idx = getSingleBuildTarget();
662663
if (Arg *A = Args.getLastArg(options::OPT_fsanitize_EQ,
663664
options::OPT_fno_sanitize_EQ)) {
664665
if (A->getOption().matches(options::OPT_fsanitize_EQ) &&
665-
A->getValues().size() == 1) {
666-
std::string SanitizeVal = A->getValue();
667-
if (SanitizeVal == "address")
668-
addSingleLibrary(SYCLDeviceAsanLibs[sanitizer_lib_idx]);
669-
}
666+
A->getValues().size() == 1)
667+
SanitizeVal = A->getValue();
670668
} else {
671669
// User can pass -fsanitize=address to device compiler via
672670
// -Xsycl-target-frontend, sanitize device library must be
673671
// linked with user's device image if so.
674-
bool IsDeviceAsanEnabled = false;
675-
auto SyclFEArg = Args.getAllArgValues(options::OPT_Xsycl_frontend);
676-
IsDeviceAsanEnabled = (std::count(SyclFEArg.begin(), SyclFEArg.end(),
677-
"-fsanitize=address") > 0);
678-
if (!IsDeviceAsanEnabled) {
679-
auto SyclFEArgEq = Args.getAllArgValues(options::OPT_Xsycl_frontend_EQ);
680-
IsDeviceAsanEnabled = (std::count(SyclFEArgEq.begin(), SyclFEArgEq.end(),
681-
"-fsanitize=address") > 0);
682-
}
683-
684-
// User can also enable asan for SYCL device via -Xarch_device option.
685-
if (!IsDeviceAsanEnabled) {
686-
auto DeviceArchVals = Args.getAllArgValues(options::OPT_Xarch_device);
687-
for (auto DArchVal : DeviceArchVals) {
688-
if (DArchVal.find("-fsanitize=address") != std::string::npos) {
689-
IsDeviceAsanEnabled = true;
690-
break;
691-
}
672+
std::vector<std::string> EnabledDeviceSanitizers;
673+
674+
// NOTE: "-fsanitize=" applies to all device targets
675+
auto SyclFEArgVals = Args.getAllArgValues(options::OPT_Xsycl_frontend);
676+
auto SyclFEEQArgVals = Args.getAllArgValues(options::OPT_Xsycl_frontend_EQ);
677+
auto ArchDeviceVals = Args.getAllArgValues(options::OPT_Xarch_device);
678+
679+
std::vector<std::string> ArgVals(
680+
SyclFEArgVals.size() + SyclFEEQArgVals.size() + ArchDeviceVals.size());
681+
ArgVals.insert(ArgVals.end(), SyclFEArgVals.begin(), SyclFEArgVals.end());
682+
ArgVals.insert(ArgVals.end(), SyclFEEQArgVals.begin(),
683+
SyclFEEQArgVals.end());
684+
ArgVals.insert(ArgVals.end(), ArchDeviceVals.begin(), ArchDeviceVals.end());
685+
686+
// Driver will report error if address sanitizer and memory sanitizer are
687+
// both enabled, so we only need to check first one here.
688+
for (const std::string &Arg : ArgVals) {
689+
if (Arg.find("-fsanitize=address") != std::string::npos) {
690+
SanitizeVal = "address";
691+
break;
692692
}
693693
}
694-
695-
if (IsDeviceAsanEnabled)
696-
addSingleLibrary(SYCLDeviceAsanLibs[sanitizer_lib_idx]);
697694
}
695+
696+
if (SanitizeVal == "address")
697+
addSingleLibrary(SYCLDeviceAsanLibs[sanitizer_lib_idx]);
698+
698699
#endif
699700

700701
if (isNativeCPU)

0 commit comments

Comments
 (0)