Skip to content

Commit

Permalink
Merge branch 'sycl' into fabio/immediate_append_exp
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiomestre authored Nov 21, 2024
2 parents 5ef79d2 + 925ff76 commit f087381
Show file tree
Hide file tree
Showing 168 changed files with 3,356 additions and 1,327 deletions.
1 change: 1 addition & 0 deletions .github/workflows/sycl-windows-run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ jobs:
cmake --build build-e2e --target check-sycl-e2e
- name: Detect hung tests
shell: powershell
if: always()
run: |
$exitCode = 0
$hungTests = Get-Process | Where-Object { ($_.Path -match "llvm\\install") -or ($_.Path -match "llvm\\build-e2e") }
Expand Down
20 changes: 15 additions & 5 deletions clang/include/clang/AST/PrettyPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,18 @@ struct PrintingPolicy {
SuppressStrongLifetime(false), SuppressLifetimeQualifiers(false),
SuppressTypedefs(false), SuppressFinalSpecifier(false),
SuppressTemplateArgsInCXXConstructors(false),
SuppressDefaultTemplateArgs(true), Bool(LO.Bool),
Nullptr(LO.CPlusPlus11 || LO.C23), NullptrTypeInNamespace(LO.CPlusPlus),
Restrict(LO.C99), Alignof(LO.CPlusPlus11), UnderscoreAlignof(LO.C11),
SuppressDefaultTemplateArgs(true), EnforceDefaultTemplateArgs(false),
Bool(LO.Bool), Nullptr(LO.CPlusPlus11 || LO.C23),
NullptrTypeInNamespace(LO.CPlusPlus), Restrict(LO.C99),
Alignof(LO.CPlusPlus11), UnderscoreAlignof(LO.C11),
UseVoidForZeroParams(!LO.CPlusPlus),
SplitTemplateClosers(!LO.CPlusPlus11), TerseOutput(false),
PolishForDeclaration(false), Half(LO.Half),
MSWChar(LO.MicrosoftExt && !LO.WChar), IncludeNewlines(true),
MSVCFormatting(false), ConstantsAsWritten(false),
SuppressImplicitBase(false), FullyQualifiedName(false),
SuppressDefinition(false), SuppressDefaultTemplateArguments(false),
PrintCanonicalTypes(false),
EnforceScopeForElaboratedTypes(false), SuppressDefinition(false),
SuppressDefaultTemplateArguments(false), PrintCanonicalTypes(false),
SkipCanonicalizationOfTemplateTypeParms(false),
PrintInjectedClassNameWithArguments(true), UsePreferredNames(true),
AlwaysIncludeTypeForTemplateArgument(false),
Expand Down Expand Up @@ -241,6 +242,11 @@ struct PrintingPolicy {
LLVM_PREFERRED_TYPE(bool)
unsigned SuppressDefaultTemplateArgs : 1;

/// When true, print template arguments that match the default argument for
/// the parameter, even if they're not specified in the source.
LLVM_PREFERRED_TYPE(bool)
unsigned EnforceDefaultTemplateArgs : 1;

/// Whether we can use 'bool' rather than '_Bool' (even if the language
/// doesn't actually have 'bool', because, e.g., it is defined as a macro).
LLVM_PREFERRED_TYPE(bool)
Expand Down Expand Up @@ -339,6 +345,10 @@ struct PrintingPolicy {
LLVM_PREFERRED_TYPE(bool)
unsigned FullyQualifiedName : 1;

/// Enforce fully qualified name printing for elaborated types.
LLVM_PREFERRED_TYPE(bool)
unsigned EnforceScopeForElaboratedTypes : 1;

/// When true does not print definition of a type. E.g.
/// \code
/// template<typename T> class C0 : public C1 {...}
Expand Down
60 changes: 39 additions & 21 deletions clang/lib/AST/TypePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class ElaboratedTypePolicyRAII {
SuppressTagKeyword = Policy.SuppressTagKeyword;
SuppressScope = Policy.SuppressScope;
Policy.SuppressTagKeyword = true;
Policy.SuppressScope = true;
Policy.SuppressScope = !Policy.EnforceScopeForElaboratedTypes;
}

~ElaboratedTypePolicyRAII() {
Expand Down Expand Up @@ -1728,8 +1728,10 @@ void TypePrinter::printElaboratedBefore(const ElaboratedType *T,
Policy.SuppressScope = OldSupressScope;
return;
}
if (Qualifier && !(Policy.SuppressTypedefs &&
T->getNamedType()->getTypeClass() == Type::Typedef))
if (Qualifier &&
!(Policy.SuppressTypedefs &&
T->getNamedType()->getTypeClass() == Type::Typedef) &&
!Policy.EnforceScopeForElaboratedTypes)
Qualifier->print(OS, Policy);
}

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

static void printArgument(const TemplateArgumentLoc &A,
const PrintingPolicy &PP, llvm::raw_ostream &OS,
bool IncludeType) {
const TemplateArgument::ArgKind &Kind = A.getArgument().getKind();
if (Kind == TemplateArgument::ArgKind::Type)
return A.getTypeSourceInfo()->getType().print(OS, PP);
return A.getArgument().print(PP, OS, IncludeType);
}

static bool isSubstitutedTemplateArgument(ASTContext &Ctx, TemplateArgument Arg,
TemplateArgument Pattern,
ArrayRef<TemplateArgument> Args,
Expand Down Expand Up @@ -2399,15 +2392,40 @@ template <typename TA>
static void
printTo(raw_ostream &OS, ArrayRef<TA> Args, const PrintingPolicy &Policy,
const TemplateParameterList *TPL, bool IsPack, unsigned ParmIndex) {
// Drop trailing template arguments that match default arguments.
if (TPL && Policy.SuppressDefaultTemplateArgs &&
!Policy.PrintCanonicalTypes && !Args.empty() && !IsPack &&
llvm::SmallVector<TemplateArgument, 8> ArgsToPrint;
for (const TA &A : Args)
ArgsToPrint.push_back(getArgument(A));
if (TPL && !Policy.PrintCanonicalTypes && !IsPack &&
Args.size() <= TPL->size()) {
llvm::SmallVector<TemplateArgument, 8> OrigArgs;
for (const TA &A : Args)
OrigArgs.push_back(getArgument(A));
while (!Args.empty() && getArgument(Args.back()).getIsDefaulted())
Args = Args.drop_back();
// Drop trailing template arguments that match default arguments.
if (Policy.SuppressDefaultTemplateArgs) {
while (!ArgsToPrint.empty() &&
getArgument(ArgsToPrint.back()).getIsDefaulted())
ArgsToPrint.pop_back();
} else if (Policy.EnforceDefaultTemplateArgs) {
for (unsigned I = Args.size(); I < TPL->size(); ++I) {
auto Param = TPL->getParam(I);
if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Param)) {
// If we met a non default-argument past provided list of arguments,
// it is either a pack which must be the last arguments, or provided
// argument list was problematic. Bail out either way. Do the same
// for each kind of template argument.
if (!TTPD->hasDefaultArgument())
break;
ArgsToPrint.push_back(getArgument(TTPD->getDefaultArgument()));
} else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Param)) {
if (!TTPD->hasDefaultArgument())
break;
ArgsToPrint.push_back(getArgument(TTPD->getDefaultArgument()));
} else if (auto *NTTPD = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
if (!NTTPD->hasDefaultArgument())
break;
ArgsToPrint.push_back(getArgument(NTTPD->getDefaultArgument()));
} else {
llvm_unreachable("unexpected template parameter");
}
}
}
}

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

bool NeedSpace = false;
bool FirstArg = true;
for (const auto &Arg : Args) {
for (const auto &Arg : ArgsToPrint) {
// Print the argument into a string.
SmallString<128> Buf;
llvm::raw_svector_ostream ArgOS(Buf);
Expand Down
7 changes: 5 additions & 2 deletions clang/lib/Driver/OffloadBundler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,8 +688,11 @@ class ObjectFileHandler final : public FileHandler {
return std::move(Err);

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

// Add symbol name with the target prefix to the buffer.
Expand Down
8 changes: 2 additions & 6 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10674,12 +10674,8 @@ static void getTripleBasedSPIRVTransOpts(Compilation &C,
ArgStringList &TranslatorArgs) {
bool IsCPU = Triple.isSPIR() &&
Triple.getSubArch() == llvm::Triple::SPIRSubArch_x86_64;
// Enable NonSemanticShaderDebugInfo.200 for CPU AOT and for non-Windows
const bool IsWindowsMSVC =
Triple.isWindowsMSVCEnvironment() ||
C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment();
const bool EnableNonSemanticDebug =
IsCPU || (!IsWindowsMSVC && !C.getDriver().IsFPGAHWMode());
// Enable NonSemanticShaderDebugInfo.200 for non-FPGA targets.
const bool EnableNonSemanticDebug = !C.getDriver().IsFPGAHWMode();
if (EnableNonSemanticDebug) {
TranslatorArgs.push_back(
"-spirv-debug-info-version=nonsemantic-shader-200");
Expand Down
5 changes: 4 additions & 1 deletion clang/lib/Driver/ToolChains/SYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,11 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
addLibraries(SYCLDeviceBfloat16FallbackLib);
}

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

#if !defined(_WIN32)
Expand Down
Loading

0 comments on commit f087381

Please sign in to comment.