Skip to content

Commit 23f1d3a

Browse files
authored
Merge branch 'sycl' into ianayl/2way-prefetch
2 parents 272adc6 + f741bdd commit 23f1d3a

File tree

249 files changed

+3687
-1465
lines changed

Some content is hidden

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

249 files changed

+3687
-1465
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ jobs:
162162
runner: '["Linux", "amdgpu"]'
163163
image: ghcr.io/intel/llvm/ubuntu2204_build:latest
164164
image_extra_opts: --device=/dev/dri --device=/dev/kfd
165-
extra_cmake_args: -DHIP_PLATFORM="AMD" -DAMD_ARCH="gfx1031"
166165
- name: CUDA system
167166
runner: '["Linux", "cuda"]'
168167
image: ghcr.io/intel/llvm/ubuntu2204_build:latest

.github/workflows/sycl-linux-run-tests.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ on:
2121
type: string
2222
required: True
2323
extra_cmake_args:
24-
description: |
25-
If empty, then HIP_PLATFORM and AMD_ARCH would be automatically added
26-
if inputs.target_devices contains 'ext_oneapi_hip'
2724
type: string
2825
required: False
2926
tests_selector:
@@ -282,16 +279,6 @@ jobs:
282279
run: |
283280
if [ -n "$CMAKE_EXTRA_ARGS" ]; then
284281
echo "opts=$CMAKE_EXTRA_ARGS" >> $GITHUB_OUTPUT
285-
else
286-
if [ "${{ contains(inputs.target_devices, 'ext_oneapi_hip') }}" == "true" ]; then
287-
if [ "${{ runner.name }}" == "cp-amd-runner" ]; then
288-
echo 'opts=-DHIP_PLATFORM="AMD" -DAMD_ARCH="gfx1030"' >> $GITHUB_OUTPUT
289-
else
290-
echo 'opts=-DHIP_PLATFORM="AMD" -DAMD_ARCH="gfx1031"' >> $GITHUB_OUTPUT
291-
fi
292-
else
293-
echo 'opts=' >> $GITHUB_OUTPUT
294-
fi
295282
fi
296283
- name: Configure E2E tests
297284
if: inputs.tests_selector == 'e2e'

.github/workflows/sycl-post-commit.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@ on:
2020
- ./devops/actions/cached_checkout
2121

2222
concurrency:
23-
# Cancel a currently running workflow from the same PR or commit hash.
24-
# We need to use the user's branch name (which is in different variables
25-
# for pull request events and push events) so that making a PR from a
26-
# sycl-devops-pr branch doesn't cause two postcommit runs.
27-
group: "${{ github.actor }}-${{ github.head_ref || github.ref_name }}"
23+
# Cancel a currently running workflow from the same PR or commit hash.
24+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
2825
cancel-in-progress: true
2926

3027
permissions: read-all

.github/workflows/sycl-windows-run-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ jobs:
8888
cmake --build build-e2e --target check-sycl-e2e
8989
- name: Detect hung tests
9090
shell: powershell
91+
if: always()
9192
run: |
9293
$exitCode = 0
9394
$hungTests = Get-Process | Where-Object { ($_.Path -match "llvm\\install") -or ($_.Path -match "llvm\\build-e2e") }

clang/include/clang/AST/PrettyPrinter.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,18 @@ struct PrintingPolicy {
6868
SuppressStrongLifetime(false), SuppressLifetimeQualifiers(false),
6969
SuppressTypedefs(false), SuppressFinalSpecifier(false),
7070
SuppressTemplateArgsInCXXConstructors(false),
71-
SuppressDefaultTemplateArgs(true), Bool(LO.Bool),
72-
Nullptr(LO.CPlusPlus11 || LO.C23), NullptrTypeInNamespace(LO.CPlusPlus),
73-
Restrict(LO.C99), Alignof(LO.CPlusPlus11), UnderscoreAlignof(LO.C11),
71+
SuppressDefaultTemplateArgs(true), EnforceDefaultTemplateArgs(false),
72+
Bool(LO.Bool), Nullptr(LO.CPlusPlus11 || LO.C23),
73+
NullptrTypeInNamespace(LO.CPlusPlus), Restrict(LO.C99),
74+
Alignof(LO.CPlusPlus11), UnderscoreAlignof(LO.C11),
7475
UseVoidForZeroParams(!LO.CPlusPlus),
7576
SplitTemplateClosers(!LO.CPlusPlus11), TerseOutput(false),
7677
PolishForDeclaration(false), Half(LO.Half),
7778
MSWChar(LO.MicrosoftExt && !LO.WChar), IncludeNewlines(true),
7879
MSVCFormatting(false), ConstantsAsWritten(false),
7980
SuppressImplicitBase(false), FullyQualifiedName(false),
80-
SuppressDefinition(false), SuppressDefaultTemplateArguments(false),
81-
PrintCanonicalTypes(false),
81+
EnforceScopeForElaboratedTypes(false), SuppressDefinition(false),
82+
SuppressDefaultTemplateArguments(false), PrintCanonicalTypes(false),
8283
SkipCanonicalizationOfTemplateTypeParms(false),
8384
PrintInjectedClassNameWithArguments(true), UsePreferredNames(true),
8485
AlwaysIncludeTypeForTemplateArgument(false),
@@ -241,6 +242,11 @@ struct PrintingPolicy {
241242
LLVM_PREFERRED_TYPE(bool)
242243
unsigned SuppressDefaultTemplateArgs : 1;
243244

245+
/// When true, print template arguments that match the default argument for
246+
/// the parameter, even if they're not specified in the source.
247+
LLVM_PREFERRED_TYPE(bool)
248+
unsigned EnforceDefaultTemplateArgs : 1;
249+
244250
/// Whether we can use 'bool' rather than '_Bool' (even if the language
245251
/// doesn't actually have 'bool', because, e.g., it is defined as a macro).
246252
LLVM_PREFERRED_TYPE(bool)
@@ -339,6 +345,10 @@ struct PrintingPolicy {
339345
LLVM_PREFERRED_TYPE(bool)
340346
unsigned FullyQualifiedName : 1;
341347

348+
/// Enforce fully qualified name printing for elaborated types.
349+
LLVM_PREFERRED_TYPE(bool)
350+
unsigned EnforceScopeForElaboratedTypes : 1;
351+
342352
/// When true does not print definition of a type. E.g.
343353
/// \code
344354
/// template<typename T> class C0 : public C1 {...}

clang/lib/AST/TypePrinter.cpp

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class ElaboratedTypePolicyRAII {
101101
SuppressTagKeyword = Policy.SuppressTagKeyword;
102102
SuppressScope = Policy.SuppressScope;
103103
Policy.SuppressTagKeyword = true;
104-
Policy.SuppressScope = true;
104+
Policy.SuppressScope = !Policy.EnforceScopeForElaboratedTypes;
105105
}
106106

107107
~ElaboratedTypePolicyRAII() {
@@ -1728,8 +1728,10 @@ void TypePrinter::printElaboratedBefore(const ElaboratedType *T,
17281728
Policy.SuppressScope = OldSupressScope;
17291729
return;
17301730
}
1731-
if (Qualifier && !(Policy.SuppressTypedefs &&
1732-
T->getNamedType()->getTypeClass() == Type::Typedef))
1731+
if (Qualifier &&
1732+
!(Policy.SuppressTypedefs &&
1733+
T->getNamedType()->getTypeClass() == Type::Typedef) &&
1734+
!Policy.EnforceScopeForElaboratedTypes)
17331735
Qualifier->print(OS, Policy);
17341736
}
17351737

@@ -2220,15 +2222,6 @@ static void printArgument(const TemplateArgument &A, const PrintingPolicy &PP,
22202222
A.print(PP, OS, IncludeType);
22212223
}
22222224

2223-
static void printArgument(const TemplateArgumentLoc &A,
2224-
const PrintingPolicy &PP, llvm::raw_ostream &OS,
2225-
bool IncludeType) {
2226-
const TemplateArgument::ArgKind &Kind = A.getArgument().getKind();
2227-
if (Kind == TemplateArgument::ArgKind::Type)
2228-
return A.getTypeSourceInfo()->getType().print(OS, PP);
2229-
return A.getArgument().print(PP, OS, IncludeType);
2230-
}
2231-
22322225
static bool isSubstitutedTemplateArgument(ASTContext &Ctx, TemplateArgument Arg,
22332226
TemplateArgument Pattern,
22342227
ArrayRef<TemplateArgument> Args,
@@ -2399,15 +2392,40 @@ template <typename TA>
23992392
static void
24002393
printTo(raw_ostream &OS, ArrayRef<TA> Args, const PrintingPolicy &Policy,
24012394
const TemplateParameterList *TPL, bool IsPack, unsigned ParmIndex) {
2402-
// Drop trailing template arguments that match default arguments.
2403-
if (TPL && Policy.SuppressDefaultTemplateArgs &&
2404-
!Policy.PrintCanonicalTypes && !Args.empty() && !IsPack &&
2395+
llvm::SmallVector<TemplateArgument, 8> ArgsToPrint;
2396+
for (const TA &A : Args)
2397+
ArgsToPrint.push_back(getArgument(A));
2398+
if (TPL && !Policy.PrintCanonicalTypes && !IsPack &&
24052399
Args.size() <= TPL->size()) {
2406-
llvm::SmallVector<TemplateArgument, 8> OrigArgs;
2407-
for (const TA &A : Args)
2408-
OrigArgs.push_back(getArgument(A));
2409-
while (!Args.empty() && getArgument(Args.back()).getIsDefaulted())
2410-
Args = Args.drop_back();
2400+
// Drop trailing template arguments that match default arguments.
2401+
if (Policy.SuppressDefaultTemplateArgs) {
2402+
while (!ArgsToPrint.empty() &&
2403+
getArgument(ArgsToPrint.back()).getIsDefaulted())
2404+
ArgsToPrint.pop_back();
2405+
} else if (Policy.EnforceDefaultTemplateArgs) {
2406+
for (unsigned I = Args.size(); I < TPL->size(); ++I) {
2407+
auto Param = TPL->getParam(I);
2408+
if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Param)) {
2409+
// If we met a non default-argument past provided list of arguments,
2410+
// it is either a pack which must be the last arguments, or provided
2411+
// argument list was problematic. Bail out either way. Do the same
2412+
// for each kind of template argument.
2413+
if (!TTPD->hasDefaultArgument())
2414+
break;
2415+
ArgsToPrint.push_back(getArgument(TTPD->getDefaultArgument()));
2416+
} else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Param)) {
2417+
if (!TTPD->hasDefaultArgument())
2418+
break;
2419+
ArgsToPrint.push_back(getArgument(TTPD->getDefaultArgument()));
2420+
} else if (auto *NTTPD = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
2421+
if (!NTTPD->hasDefaultArgument())
2422+
break;
2423+
ArgsToPrint.push_back(getArgument(NTTPD->getDefaultArgument()));
2424+
} else {
2425+
llvm_unreachable("unexpected template parameter");
2426+
}
2427+
}
2428+
}
24112429
}
24122430

24132431
const char *Comma = Policy.MSVCFormatting ? "," : ", ";
@@ -2416,7 +2434,7 @@ printTo(raw_ostream &OS, ArrayRef<TA> Args, const PrintingPolicy &Policy,
24162434

24172435
bool NeedSpace = false;
24182436
bool FirstArg = true;
2419-
for (const auto &Arg : Args) {
2437+
for (const auto &Arg : ArgsToPrint) {
24202438
// Print the argument into a string.
24212439
SmallString<128> Buf;
24222440
llvm::raw_svector_ostream ArgOS(Buf);

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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11471,6 +11471,12 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
1147111471
if (Args.hasArg(options::OPT_fsycl_embed_ir))
1147211472
CmdArgs.push_back(Args.MakeArgString("-sycl-embed-ir"));
1147311473

11474+
if (Args.hasFlag(options::OPT_fsycl_allow_device_image_dependencies,
11475+
options::OPT_fno_sycl_allow_device_image_dependencies,
11476+
false))
11477+
CmdArgs.push_back(
11478+
Args.MakeArgString("-sycl-allow-device-image-dependencies"));
11479+
1147411480
// Formulate and add any offload-wrapper and AOT specific options. These
1147511481
// are additional options passed in via -Xsycl-target-linker and
1147611482
// -Xsycl-target-backend.

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,8 +650,11 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
650650
addLibraries(SYCLDeviceBfloat16FallbackLib);
651651
}
652652

653+
// Link in ITT annotations library unless fsycl-no-instrument-device-code
654+
// is specified. This ensures that we are ABI-compatible with the
655+
// instrumented device code, which was the default not so long ago.
653656
if (Args.hasFlag(options::OPT_fsycl_instrument_device_code,
654-
options::OPT_fno_sycl_instrument_device_code, false))
657+
options::OPT_fno_sycl_instrument_device_code, true))
655658
addLibraries(SYCLDeviceAnnotationLibs);
656659

657660
#if !defined(_WIN32)

clang/lib/Driver/ToolChains/SYCL.h

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- SYCL.h - SYCL ToolChain Implementations -----------------*- C++ -*-===//
1+
//===--- SYCL.h - SYCL ToolChain Implementations ----------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -158,8 +158,8 @@ SmallVector<std::string, 8> getDeviceLibraries(const Compilation &C,
158158
bool IsSpirvAOT);
159159

160160
// Populates the SYCL device traits macros.
161-
void populateSYCLDeviceTraitsMacrosArgs(Compilation &C,
162-
const llvm::opt::ArgList &Args,
161+
void populateSYCLDeviceTraitsMacrosArgs(
162+
Compilation &C, const llvm::opt::ArgList &Args,
163163
const SmallVectorImpl<std::pair<const ToolChain *, StringRef>> &Targets);
164164

165165
bool shouldDoPerObjectFileLinking(const Compilation &C);
@@ -180,11 +180,11 @@ class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
180180
private:
181181
/// \return llvm-link output file name.
182182
const char *constructLLVMLinkCommand(Compilation &C, const JobAction &JA,
183-
const InputInfo &Output,
184-
const llvm::opt::ArgList &Args,
185-
llvm::StringRef SubArchName,
186-
llvm::StringRef OutputFilePrefix,
187-
const InputInfoList &InputFiles) const;
183+
const InputInfo &Output,
184+
const llvm::opt::ArgList &Args,
185+
llvm::StringRef SubArchName,
186+
llvm::StringRef OutputFilePrefix,
187+
const InputInfoList &InputFiles) const;
188188
};
189189

190190
/// Directly call FPGA Compiler and Linker
@@ -241,7 +241,7 @@ template <auto GPUArh> std::optional<StringRef> isGPUTarget(StringRef Target) {
241241
if (Target.starts_with(GPUArh)) {
242242
return resolveGenDevice(Target);
243243
}
244-
return std::nullopt;
244+
return std::nullopt;
245245
}
246246

247247
} // end namespace gen
@@ -280,9 +280,10 @@ class LLVM_LIBRARY_VISIBILITY SYCLToolChain : public ToolChain {
280280
llvm::opt::DerivedArgList *
281281
TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
282282
Action::OffloadKind DeviceOffloadKind) const override;
283-
void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
284-
llvm::opt::ArgStringList &CC1Args,
285-
Action::OffloadKind DeviceOffloadKind) const override;
283+
void
284+
addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
285+
llvm::opt::ArgStringList &CC1Args,
286+
Action::OffloadKind DeviceOffloadKind) const override;
286287
void AddImpliedTargetArgs(const llvm::Triple &Triple,
287288
const llvm::opt::ArgList &Args,
288289
llvm::opt::ArgStringList &CmdArgs,
@@ -324,7 +325,8 @@ class LLVM_LIBRARY_VISIBILITY SYCLToolChain : public ToolChain {
324325
CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
325326
void AddSYCLIncludeArgs(const llvm::opt::ArgList &DriverArgs,
326327
llvm::opt::ArgStringList &CC1Args) const override;
327-
void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
328+
void
329+
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
328330
llvm::opt::ArgStringList &CC1Args) const override;
329331
void AddClangCXXStdlibIncludeArgs(
330332
const llvm::opt::ArgList &Args,
@@ -357,7 +359,8 @@ inline bool isSYCLNativeCPU(const llvm::opt::ArgList &Args) {
357359
return false;
358360
}
359361

360-
inline bool isSYCLNativeCPU(const llvm::Triple &HostT, const llvm::Triple &DevT) {
362+
inline bool isSYCLNativeCPU(const llvm::Triple &HostT,
363+
const llvm::Triple &DevT) {
361364
return HostT == DevT;
362365
}
363366

0 commit comments

Comments
 (0)