Skip to content

Commit 533dffc

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents 2a5a4fd + 3baec18 commit 533dffc

File tree

104 files changed

+4029
-2898
lines changed

Some content is hidden

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

104 files changed

+4029
-2898
lines changed

buildbot/configure.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ def do_configure(args):
1111
sycl_dir = os.path.join(args.src_dir, "sycl")
1212
spirv_dir = os.path.join(args.src_dir, "llvm-spirv")
1313
xpti_dir = os.path.join(args.src_dir, "xpti")
14+
libdevice_dir = os.path.join(args.src_dir, "libdevice")
1415
ocl_header_dir = os.path.join(args.obj_dir, "OpenCL-Headers")
1516
icd_loader_lib = os.path.join(args.obj_dir, "OpenCL-ICD-Loader", "build")
1617
llvm_targets_to_build = 'X86'
17-
llvm_enable_projects = 'clang;llvm-spirv;sycl;opencl-aot;xpti'
18+
llvm_enable_projects = 'clang;llvm-spirv;sycl;opencl-aot;xpti;libdevice'
1819
libclc_targets_to_build = ''
1920
sycl_build_pi_cuda = 'OFF'
2021
llvm_enable_assertions = 'ON'
@@ -49,10 +50,11 @@ def do_configure(args):
4950
"-DCMAKE_BUILD_TYPE={}".format(args.build_type),
5051
"-DLLVM_ENABLE_ASSERTIONS={}".format(llvm_enable_assertions),
5152
"-DLLVM_TARGETS_TO_BUILD={}".format(llvm_targets_to_build),
52-
"-DLLVM_EXTERNAL_PROJECTS=sycl;llvm-spirv;opencl-aot;xpti",
53+
"-DLLVM_EXTERNAL_PROJECTS=sycl;llvm-spirv;opencl-aot;xpti;libdevice",
5354
"-DLLVM_EXTERNAL_SYCL_SOURCE_DIR={}".format(sycl_dir),
5455
"-DLLVM_EXTERNAL_LLVM_SPIRV_SOURCE_DIR={}".format(spirv_dir),
5556
"-DLLVM_EXTERNAL_XPTI_SOURCE_DIR={}".format(xpti_dir),
57+
"-DLLVM_EXTERNAL_LIBDEVICE_SOURCE_DIR={}".format(libdevice_dir),
5658
"-DLLVM_ENABLE_PROJECTS={}".format(llvm_enable_projects),
5759
"-DLIBCLC_TARGETS_TO_BUILD={}".format(libclc_targets_to_build),
5860
"-DSYCL_BUILD_PI_CUDA={}".format(sycl_build_pi_cuda),

clang/include/clang/Basic/AttrDocs.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,8 +2117,8 @@ def SYCLDeviceIndirectlyCallableDocs : Documentation {
21172117
This attribute can only be applied to functions and indicates that the
21182118
function must be treated as a device function and must be emitted even if it has
21192119
no direct uses from other SYCL device functions. However, it cannot be applied
2120-
to functions marked as 'static', functions declared within an anonymous
2121-
namespace or class member functions.
2120+
to functions marked as 'static' and functions declared within an anonymous
2121+
namespace.
21222122

21232123
It also means that function should be available externally and
21242124
cannot be optimized out due to reachability analysis or by any other

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ def warn_drv_object_size_disabled_O0 : Warning<
340340
InGroup<InvalidCommandLineArgument>, DefaultWarnNoWerror;
341341
def err_invalid_branch_protection: Error <
342342
"invalid branch protection option '%0' in '%1'">;
343+
def warn_drv_deprecated_option : Warning<
344+
"option '%0' is deprecated, use '%1' directly instead">, InGroup<Deprecated>;
343345

344346
def note_drv_command_failed_diag_msg : Note<
345347
"diagnostic msg: %0">;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10690,8 +10690,7 @@ def warn_boolean_attribute_argument_is_not_valid: Warning<
1069010690
InGroup<AdjustedAttributes>;
1069110691
def err_sycl_attibute_cannot_be_applied_here
1069210692
: Error<"%0 attribute cannot be applied to a "
10693-
"%select{static function or function in an anonymous namespace"
10694-
"|class member function}1">;
10693+
"static function or function in an anonymous namespace">;
1069510694
def warn_sycl_attibute_function_raw_ptr
1069610695
: Warning<"SYCL 1.2.1 specification does not allow %0 attribute applied "
1069710696
"to a function with a raw pointer "

clang/include/clang/Basic/LangOptions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ LANGOPT(SYCLAllowFuncPtr , 1, 0, "Allow function pointers in SYCL device code")
238238
LANGOPT(SYCLStdLayoutKernelParams, 1, 0, "Enable standard layout requirement for SYCL kernel parameters")
239239
LANGOPT(SYCLUnnamedLambda , 1, 0, "Allow unnamed lambda SYCL kernels")
240240
LANGOPT(SYCLVersion , 32, 0, "Version of the SYCL standard used")
241+
LANGOPT(DeclareSPIRVBuiltins, 1, 0, "Declare SPIR-V builtin functions")
241242

242243
LANGOPT(HIPUseNewLaunchAPI, 1, 0, "Use new kernel launching API for HIP")
243244

clang/include/clang/Driver/Action.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class Action {
7676
SPIRVTranslatorJobClass,
7777
SPIRCheckJobClass,
7878
SYCLPostLinkJobClass,
79+
PartialLinkJobClass,
7980
BackendCompileJobClass,
8081

8182
JobClassFirst = PreprocessJobClass,
@@ -680,6 +681,18 @@ class SYCLPostLinkJobAction : public JobAction {
680681
}
681682
};
682683

684+
class PartialLinkJobAction : public JobAction {
685+
void anchor() override;
686+
687+
public:
688+
PartialLinkJobAction(Action *Input, types::ID OutputType);
689+
PartialLinkJobAction(ActionList &Input, types::ID OutputType);
690+
691+
static bool classof(const Action *A) {
692+
return A->getKind() == PartialLinkJobClass;
693+
}
694+
};
695+
683696
class BackendCompileJobAction : public JobAction {
684697
void anchor() override;
685698

clang/include/clang/Driver/CC1Options.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,8 @@ def finclude_default_header : Flag<["-"], "finclude-default-header">,
807807
HelpText<"Include default header file for OpenCL">;
808808
def fdeclare_opencl_builtins : Flag<["-"], "fdeclare-opencl-builtins">,
809809
HelpText<"Add OpenCL builtin function declarations (experimental)">;
810+
def fdeclare_spirv_builtins : Flag<["-"], "fdeclare-spirv-builtins">,
811+
HelpText<"Add SPIR-V builtin function declarations (experimental)">;
810812
def fpreserve_vec3_type : Flag<["-"], "fpreserve-vec3-type">,
811813
HelpText<"Preserve 3-component vector type">;
812814
def fwchar_type_EQ : Joined<["-"], "fwchar-type=">,

clang/include/clang/Driver/Driver.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,15 @@ class Driver {
621621
&CachedResults,
622622
Action::OffloadKind TargetDeviceOffloadKind) const;
623623

624+
/// Static offload library seen.
625+
bool OffloadStaticLibSeen = false;
626+
627+
void setOffloadStaticLibSeen() { OffloadStaticLibSeen = true; }
628+
629+
/// Returns true if an offload static library is found.
630+
bool checkForOffloadStaticLib(Compilation &C,
631+
llvm::opt::DerivedArgList &Args) const;
632+
624633
public:
625634
/// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and
626635
/// return the grouped values as integers. Numbers which are not
@@ -642,6 +651,8 @@ class Driver {
642651
MutableArrayRef<unsigned> Digits);
643652
/// Compute the default -fmodule-cache-path.
644653
static void getDefaultModuleCachePath(SmallVectorImpl<char> &Result);
654+
655+
bool getOffloadStaticLibSeen() const { return OffloadStaticLibSeen; };
645656
};
646657

647658
/// \return True if the last defined optimization level is -Ofast.
@@ -651,6 +662,9 @@ bool isOptimizationLevelFast(const llvm::opt::ArgList &Args);
651662
/// \return True if the filename has a valid object file extension.
652663
bool isObjectFile(std::string FileName);
653664

665+
/// \return True if the filename has a static archive/lib extension.
666+
bool isStaticArchiveFile(const StringRef &FileName);
667+
654668
/// \return True if the argument combination will end up generating remarks.
655669
bool willEmitRemarks(const llvm::opt::ArgList &Args);
656670

clang/include/clang/Driver/ToolChain.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ class ToolChain {
145145
mutable std::unique_ptr<Tool> SPIRVTranslator;
146146
mutable std::unique_ptr<Tool> SPIRCheck;
147147
mutable std::unique_ptr<Tool> SYCLPostLink;
148+
mutable std::unique_ptr<Tool> PartialLink;
148149
mutable std::unique_ptr<Tool> BackendCompiler;
149150

150151
Tool *getClang() const;
@@ -158,6 +159,7 @@ class ToolChain {
158159
Tool *getSPIRVTranslator() const;
159160
Tool *getSPIRCheck() const;
160161
Tool *getSYCLPostLink() const;
162+
Tool *getPartialLink() const;
161163
Tool *getBackendCompiler() const;
162164

163165
mutable std::unique_ptr<SanitizerArgs> SanitizerArguments;

clang/lib/AST/ASTContext.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10191,6 +10191,10 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) {
1019110191
if (D->hasAttr<AliasAttr>() || D->hasAttr<UsedAttr>())
1019210192
return true;
1019310193

10194+
if (LangOpts.SYCLIsDevice && !D->hasAttr<OpenCLKernelAttr>() &&
10195+
!D->hasAttr<SYCLDeviceAttr>())
10196+
return false;
10197+
1019410198
if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
1019510199
// Forward declarations aren't required.
1019610200
if (!FD->doesThisDeclarationHaveABody())
@@ -10213,6 +10217,16 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) {
1021310217
}
1021410218
}
1021510219

10220+
// Methods explcitly marked with 'sycl_device' attribute (via SYCL_EXTERNAL)
10221+
// or `indirectly_callable' attribute must be emitted regardless of number
10222+
// of actual uses
10223+
if (LangOpts.SYCLIsDevice && isa<CXXMethodDecl>(D)) {
10224+
if (auto *A = D->getAttr<SYCLDeviceIndirectlyCallableAttr>())
10225+
return !A->isImplicit();
10226+
if (auto *A = D->getAttr<SYCLDeviceAttr>())
10227+
return !A->isImplicit();
10228+
}
10229+
1021610230
GVALinkage Linkage = GetGVALinkageForFunction(FD);
1021710231

1021810232
// static, static inline, always_inline, and extern inline functions can

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2516,11 +2516,6 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) {
25162516
if (Global->hasAttr<IFuncAttr>())
25172517
return emitIFuncDefinition(GD);
25182518

2519-
if (LangOpts.SYCLIsDevice) {
2520-
if (!Global->hasAttr<SYCLDeviceAttr>())
2521-
return;
2522-
}
2523-
25242519
// If this is a cpu_dispatch multiversion function, emit the resolver.
25252520
if (Global->hasAttr<CPUDispatchAttr>())
25262521
return emitCPUDispatchDefinition(GD);
@@ -2565,6 +2560,11 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) {
25652560
}
25662561
}
25672562

2563+
if (LangOpts.SYCLIsDevice && MustBeEmitted(Global)) {
2564+
addDeferredDeclToEmit(GD);
2565+
return;
2566+
}
2567+
25682568
// Ignore declarations, they will be emitted on their first use.
25692569
if (const auto *FD = dyn_cast<FunctionDecl>(Global)) {
25702570
// Forward declarations are emitted lazily on first use.

clang/lib/Driver/Action.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ const char *Action::getClassName(ActionClass AC) {
4949
return "llvm-no-spir-kernel";
5050
case SYCLPostLinkJobClass:
5151
return "sycl-post-link";
52+
case PartialLinkJobClass:
53+
return "partial-link";
5254
case BackendCompileJobClass:
5355
return "backend-compiler";
5456
}
@@ -454,6 +456,14 @@ void SYCLPostLinkJobAction::anchor() {}
454456
SYCLPostLinkJobAction::SYCLPostLinkJobAction(Action *Input, types::ID Type)
455457
: JobAction(SYCLPostLinkJobClass, Input, Type) {}
456458

459+
void PartialLinkJobAction::anchor() {}
460+
461+
PartialLinkJobAction::PartialLinkJobAction(Action *Input, types::ID Type)
462+
: JobAction(PartialLinkJobClass, Input, Type) {}
463+
464+
PartialLinkJobAction::PartialLinkJobAction(ActionList &Inputs, types::ID Type)
465+
: JobAction(PartialLinkJobClass, Inputs, Type) {}
466+
457467
void BackendCompileJobAction::anchor() {}
458468

459469
BackendCompileJobAction::BackendCompileJobAction(ActionList &Inputs,

0 commit comments

Comments
 (0)