Skip to content

Commit 682c64c

Browse files
committed
Merge remote-tracking branch 'upstream/sycl' into sycl
2 parents eaa89ca + 9134bfa commit 682c64c

File tree

99 files changed

+2019
-1275
lines changed

Some content is hidden

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

99 files changed

+2019
-1275
lines changed

.github/workflows/gh_pages.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ jobs:
1212
with:
1313
ref: sycl
1414
path: repo
15-
- uses: actions/checkout@v2
16-
with:
17-
repository: intel/llvm-docs
18-
path: docs
1915
- name: Install deps
2016
run: sudo apt-get install -y doxygen graphviz ssh ninja-build
2117
- name: Build Docs
@@ -34,6 +30,7 @@ jobs:
3430
chmod 600 ~/.ssh/id_rsa
3531
eval "$(ssh-agent -s)"
3632
ssh-add -k ~/.ssh/id_rsa
33+
git clone [email protected]:intel/llvm-docs.git docs
3734
cd $GITHUB_WORKSPACE/docs
3835
yes | \cp -rf $GITHUB_WORKSPACE/build/tools/sycl/doc/doxygen/html/* .
3936
git config --global user.name "iclsrc"

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,8 @@ def warn_drv_treating_input_as_cxx : Warning<
324324
InGroup<Deprecated>;
325325
def warn_drv_pch_not_first_include : Warning<
326326
"precompiled header '%0' was ignored because '%1' is not first '-include'">;
327+
def warn_drv_existing_archive_append: Warning<
328+
"appending to an existing archive '%0'">, InGroup<DiagGroup<"archive-append">>;
327329
def warn_missing_sysroot : Warning<"no such sysroot directory: '%0'">,
328330
InGroup<DiagGroup<"missing-sysroot">>;
329331
def warn_incompatible_sysroot : Warning<"using sysroot for '%0' but targeting '%1'">,

clang/include/clang/Driver/Types.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,5 @@ TYPE("wholearchive", WholeArchive, INVALID, "a", phases
110110
TYPE("fpga_aocx", FPGA_AOCX, INVALID, "aocx", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
111111
TYPE("fpga_aocr", FPGA_AOCR, INVALID, "aocr", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
112112
TYPE("fpga_aoco", FPGA_AOCO, INVALID, "aoco", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
113+
TYPE("fpga_dependencies", FPGA_Dependencies, INVALID, "d", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
113114
TYPE("none", Nothing, INVALID, nullptr, phases::Compile, phases::Backend, phases::Assemble, phases::Link)

clang/lib/CodeGen/CGSYCLRuntime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ bool Util::matchQualifiedTypeName(const CXXRecordDecl *RecTy,
104104
// (namespace) and name.
105105
if (!RecTy)
106106
return false; // only classes/structs supported
107-
const auto *Ctx = dyn_cast<DeclContext>(RecTy);
107+
const auto *Ctx = cast<DeclContext>(RecTy);
108108
StringRef Name = "";
109109

110110
for (const auto &Scope : llvm::reverse(Scopes)) {

clang/lib/CodeGen/SYCLLowerIR/LowerWGScope.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -662,14 +662,14 @@ static void fixupPrivateMemoryPFWILambdaCaptures(CallInst *PFWICall) {
662662
// now rewrite the captured addresss of a private_memory variables within the
663663
// PFWI lambda object:
664664
for (auto &C : PrivMemCaptures) {
665-
GetElementPtrInst *NewGEP = dyn_cast<GetElementPtrInst>(C.second->clone());
665+
GetElementPtrInst *NewGEP = cast<GetElementPtrInst>(C.second->clone());
666666
NewGEP->insertBefore(PFWICall);
667667
IRBuilder<> Bld(PFWICall->getContext());
668668
Bld.SetInsertPoint(PFWICall);
669669
Value *Val = C.first;
670-
auto ValAS = dyn_cast<PointerType>(Val->getType())->getAddressSpace();
671-
auto PtrAS = dyn_cast<PointerType>(NewGEP->getResultElementType())
672-
->getAddressSpace();
670+
auto ValAS = cast<PointerType>(Val->getType())->getAddressSpace();
671+
auto PtrAS =
672+
cast<PointerType>(NewGEP->getResultElementType())->getAddressSpace();
673673

674674
if (ValAS != PtrAS)
675675
Val = Bld.CreateAddrSpaceCast(Val, NewGEP->getResultElementType());

clang/lib/Driver/Driver.cpp

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3253,6 +3253,9 @@ class OffloadingActionBuilder final {
32533253
/// Type of output file for FPGA device compilation.
32543254
types::ID FPGAOutType = types::TY_FPGA_AOCX;
32553255

3256+
/// List of objects to extract FPGA dependency info from
3257+
ActionList FPGAObjectInputs;
3258+
32563259
/// List of CUDA architectures to use in this compilation with NVPTX targets.
32573260
SmallVector<CudaArch, 8> GpuArchList;
32583261

@@ -3417,8 +3420,12 @@ class OffloadingActionBuilder final {
34173420
// Check if the type of the file is the same as the action. Do not
34183421
// unbundle it if it is not. Do not unbundle .so files, for example,
34193422
// which are not object files.
3420-
if (IA->getType() == types::TY_Object && !isObjectFile(FileName))
3421-
return ABRT_Inactive;
3423+
if (IA->getType() == types::TY_Object) {
3424+
if (!isObjectFile(FileName))
3425+
return ABRT_Inactive;
3426+
if (Args.hasArg(options::OPT_fintelfpga))
3427+
FPGAObjectInputs.push_back(IA);
3428+
}
34223429
// When creating FPGA device fat objects, all host objects are
34233430
// partially linked. Gather that list here.
34243431
if (IA->getType() == types::TY_Object ||
@@ -3598,6 +3605,15 @@ class OffloadingActionBuilder final {
35983605
Action *DeviceBECompileAction;
35993606
ActionList BEActionList;
36003607
BEActionList.push_back(DeviceLinkAction);
3608+
for (Action *A : FPGAObjectInputs) {
3609+
// Send any known objects through the unbundler to grab the
3610+
// dependency file associated.
3611+
ActionList AL;
3612+
AL.push_back(A);
3613+
Action *UnbundleAction = C.MakeAction<OffloadUnbundlingJobAction>(
3614+
AL, types::TY_FPGA_Dependencies);
3615+
BEActionList.push_back(UnbundleAction);
3616+
}
36013617
for (const auto &A : DeviceLibObjects)
36023618
BEActionList.push_back(A);
36033619
DeviceBECompileAction =
@@ -4462,8 +4478,8 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
44624478
IA->getInputArg().getOption().hasFlag(options::LinkerInput))
44634479
// Pass the Input along to linker only.
44644480
continue;
4465-
UnbundlerInputs.push_back(LI);
44664481
}
4482+
UnbundlerInputs.push_back(LI);
44674483
}
44684484
const Arg *LastArg;
44694485
auto addUnbundlerInput = [&](types::ID T, const Arg *A) {
@@ -5484,14 +5500,25 @@ InputInfo Driver::BuildJobsForActionNoCache(
54845500
DependentOffloadKind)}] =
54855501
CurI;
54865502
}
5487-
5488-
// Now that we have all the results generated, select the one that should be
5489-
// returned for the current depending action.
5490-
std::pair<const Action *, std::string> ActionTC = {
5491-
A, GetTriplePlusArchString(TC, BoundArch, TargetDeviceOffloadKind)};
5492-
assert(CachedResults.find(ActionTC) != CachedResults.end() &&
5493-
"Result does not exist??");
5494-
Result = CachedResults[ActionTC];
5503+
// Do a check for a dependency file unbundle for FPGA. This is out of line
5504+
// from a regular unbundle, so just create and return the name of the
5505+
// unbundled file.
5506+
if (JA->getType() == types::TY_FPGA_Dependencies) {
5507+
std::string TmpFileName =
5508+
C.getDriver().GetTemporaryPath(llvm::sys::path::stem(BaseInput), "d");
5509+
const char *TmpFile =
5510+
C.addTempFile(C.getArgs().MakeArgString(TmpFileName));
5511+
Result = InputInfo(types::TY_FPGA_Dependencies, TmpFile, TmpFile);
5512+
UnbundlingResults.push_back(Result);
5513+
} else {
5514+
// Now that we have all the results generated, select the one that should
5515+
// be returned for the current depending action.
5516+
std::pair<const Action *, std::string> ActionTC = {
5517+
A, GetTriplePlusArchString(TC, BoundArch, TargetDeviceOffloadKind)};
5518+
assert(CachedResults.find(ActionTC) != CachedResults.end() &&
5519+
"Result does not exist??");
5520+
Result = CachedResults[ActionTC];
5521+
}
54955522
} else if (JA->getType() == types::TY_Nothing)
54965523
Result = InputInfo(A, BaseInput);
54975524
else {

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,8 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
11391139
} else if (!ArgMD) {
11401140
DepFile = "-";
11411141
} else if (ArgMD->getOption().matches(options::OPT_MMD) &&
1142-
Args.hasArg(options::OPT_fintelfpga)) {
1142+
Args.hasArg(options::OPT_fintelfpga) &&
1143+
!Args.hasArg(options::OPT_c)) {
11431144
// When generating dependency files for FPGA AOT, the output files will
11441145
// always be named after the source file.
11451146
DepFile = Args.MakeArgString(Twine(getBaseInputStem(Args, Inputs)) + ".d");
@@ -3944,10 +3945,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
39443945
// Check number of inputs for sanity. We need at least one input.
39453946
assert(Inputs.size() >= 1 && "Must have at least one input.");
39463947
// CUDA/HIP compilation may have multiple inputs (source file + results of
3947-
// device-side compilations). OpenMP and SYCL device jobs also take the host
3948-
// IR as a second input. Module precompilation accepts a list of header files
3949-
// to include as part of the module. All other jobs are expected to have
3950-
// exactly one input.
3948+
// device-side compilations).
3949+
// OpenMP device jobs take the host IR as a second input.
3950+
// SYCL host jobs accept the integration header from the device-side
3951+
// compilation as a second input.
3952+
// Module precompilation accepts a list of header files to include as part
3953+
// of the module.
3954+
// All other jobs are expected to have exactly one input.
39513955
bool IsCuda = JA.isOffloading(Action::OFK_Cuda);
39523956
bool IsHIP = JA.isOffloading(Action::OFK_HIP);
39533957
bool IsOpenMPDevice = JA.isDeviceOffloading(Action::OFK_OpenMP);
@@ -4742,6 +4746,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
47424746
// `--gpu-use-aux-triple-only` is specified.
47434747
if (!Args.getLastArg(options::OPT_gpu_use_aux_triple_only) &&
47444748
((IsCuda && JA.isDeviceOffloading(Action::OFK_Cuda)) ||
4749+
(IsSYCL && IsSYCLOffloadDevice) ||
47454750
(IsHIP && JA.isDeviceOffloading(Action::OFK_HIP)))) {
47464751
const ArgList &HostArgs =
47474752
C.getArgsForToolChain(nullptr, StringRef(), Action::OFK_None);
@@ -6782,7 +6787,8 @@ const char *Clang::getDependencyFileName(const ArgList &Args,
67826787
const InputInfoList &Inputs) {
67836788
// FIXME: Think about this more.
67846789

6785-
if (Arg *OutputOpt = Args.getLastArg(options::OPT_o)) {
6790+
if (Arg *OutputOpt =
6791+
Args.getLastArg(options::OPT_o, options::OPT__SLASH_Fo)) {
67866792
SmallString<128> OutputFilename(OutputOpt->getValue());
67876793
llvm::sys::path::replace_extension(OutputFilename, llvm::Twine('d'));
67886794
return Args.MakeArgString(OutputFilename);
@@ -7094,6 +7100,20 @@ void OffloadBundler::ConstructJob(Compilation &C, const JobAction &JA,
70947100
Triples += CurDep->getOffloadingArch();
70957101
}
70967102
}
7103+
bool IsFPGADepBundle = (TCArgs.hasArg(options::OPT_fintelfpga) &&
7104+
Output.getType() == types::TY_Object);
7105+
// For -fintelfpga, when bundling objects we also want to bundle up the
7106+
// named dependency file.
7107+
// TODO - We are currently using the target triple inputs to slot a location
7108+
// of the dependency information into the bundle. It would be good to
7109+
// separate this out to an explicit option in the bundler for the dependency
7110+
// file as it does not match the type being bundled.
7111+
if (IsFPGADepBundle) {
7112+
Triples += ',';
7113+
Triples += Action::GetOffloadKindName(Action::OFK_SYCL);
7114+
Triples += '-';
7115+
Triples += llvm::Triple::getArchTypeName(llvm::Triple::fpga_dep);
7116+
}
70977117
CmdArgs.push_back(TCArgs.MakeArgString(Triples));
70987118

70997119
// Get bundled file command.
@@ -7118,6 +7138,14 @@ void OffloadBundler::ConstructJob(Compilation &C, const JobAction &JA,
71187138
}
71197139
UB += CurTC->getInputFilename(Inputs[I]);
71207140
}
7141+
// For -fintelfpga, when bundling objects we also want to bundle up the
7142+
// named dependency file.
7143+
if (IsFPGADepBundle) {
7144+
SmallString<128> CurOutput(Output.getFilename());
7145+
llvm::sys::path::replace_extension(CurOutput, "d");
7146+
UB += ',';
7147+
UB += CurOutput;
7148+
}
71217149
CmdArgs.push_back(TCArgs.MakeArgString(UB));
71227150

71237151
// All the inputs are encoded as commands.
@@ -7148,6 +7176,7 @@ void OffloadBundler::ConstructJobMultipleOutputs(
71487176
bool IsMSVCEnv =
71497177
C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment();
71507178
types::ID InputType(Input.getType());
7179+
bool IsFPGADepUnbundle = (JA.getType() == types::TY_FPGA_Dependencies);
71517180

71527181
// For Linux, we have initial support for fat archives (archives which
71537182
// contain bundled objects). We will perform partial linking against the
@@ -7207,6 +7236,8 @@ void OffloadBundler::ConstructJobMultipleOutputs(
72077236
if (InputType == types::TY_FPGA_AOCO ||
72087237
(IsMSVCEnv && types::isArchive(InputType)))
72097238
TypeArg = "aoo";
7239+
if (IsFPGADepUnbundle)
7240+
TypeArg = "o";
72107241

72117242
// Get the type.
72127243
CmdArgs.push_back(TCArgs.MakeArgString(Twine("-type=") + TypeArg));
@@ -7262,7 +7293,15 @@ void OffloadBundler::ConstructJobMultipleOutputs(
72627293
Triples += Dep.DependentBoundArch;
72637294
}
72647295
}
7265-
7296+
if (IsFPGADepUnbundle) {
7297+
// TODO - We are currently using the target triple inputs to slot a location
7298+
// of the dependency information into the bundle. It would be good to
7299+
// separate this out to an explicit option in the bundler for the dependency
7300+
// file as it does not match the type being bundled.
7301+
Triples += Action::GetOffloadKindName(Action::OFK_SYCL);
7302+
Triples += '-';
7303+
Triples += llvm::Triple::getArchTypeName(llvm::Triple::fpga_dep);
7304+
}
72667305
CmdArgs.push_back(TCArgs.MakeArgString(Triples));
72677306

72687307
// Get bundled file command.
@@ -7272,10 +7311,17 @@ void OffloadBundler::ConstructJobMultipleOutputs(
72727311
// Get unbundled files command.
72737312
SmallString<128> UB;
72747313
UB += "-outputs=";
7275-
for (unsigned I = 0; I < Outputs.size(); ++I) {
7276-
if (I)
7277-
UB += ',';
7278-
UB += DepInfo[I].DependentToolChain->getInputFilename(Outputs[I]);
7314+
// When dealing with -fintelfpga, there is an additional unbundle step
7315+
// that occurs for the dependency file. In that case, do not use the
7316+
// dependent information, but just the output file.
7317+
if (IsFPGADepUnbundle)
7318+
UB += Outputs[0].getFilename();
7319+
else {
7320+
for (unsigned I = 0; I < Outputs.size(); ++I) {
7321+
if (I)
7322+
UB += ',';
7323+
UB += DepInfo[I].DependentToolChain->getInputFilename(Outputs[I]);
7324+
}
72797325
}
72807326
CmdArgs.push_back(TCArgs.MakeArgString(UB));
72817327
CmdArgs.push_back("-unbundle");

clang/lib/Driver/ToolChains/Gnu.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,12 @@ void tools::gnutools::Linker::constructLLVMARCommand(
348348
const InputInfoList &Input, const ArgList &Args) const {
349349
ArgStringList CmdArgs;
350350
CmdArgs.push_back("cr");
351-
CmdArgs.push_back(Output.getFilename());
351+
const char *OutputFilename = Output.getFilename();
352+
if (llvm::sys::fs::exists(OutputFilename)) {
353+
C.getDriver().Diag(clang::diag::warn_drv_existing_archive_append)
354+
<< OutputFilename;
355+
}
356+
CmdArgs.push_back(OutputFilename);
352357
for (const auto &II : Input) {
353358
if (II.getType() == types::TY_Tempfilelist) {
354359
// Take the list file and pass it in with '@'.

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ void SYCL::fpga::BackendCompiler::ConstructJob(Compilation &C,
208208
"Unsupported target");
209209

210210
InputInfoList ForeachInputs;
211+
InputInfoList FPGADepFiles;
211212
ArgStringList CmdArgs{"-o", Output.getFilename()};
212213
for (const auto &II : Inputs) {
213214
std::string Filename(II.getFilename());
@@ -217,6 +218,8 @@ void SYCL::fpga::BackendCompiler::ConstructJob(Compilation &C,
217218
// Add any FPGA library lists. These come in as special tempfile lists.
218219
CmdArgs.push_back(Args.MakeArgString(Twine("-library-list=") +
219220
Filename));
221+
else if (II.getType() == types::TY_FPGA_Dependencies)
222+
FPGADepFiles.push_back(II);
220223
else
221224
CmdArgs.push_back(C.getArgs().MakeArgString(Filename));
222225
}
@@ -229,8 +232,6 @@ void SYCL::fpga::BackendCompiler::ConstructJob(Compilation &C,
229232
ForeachExt = "aocr";
230233
}
231234

232-
233-
InputInfoList FPGADepFiles;
234235
for (auto *A : Args) {
235236
// Any input file is assumed to have a dependency file associated
236237
if (A->getOption().getKind() == Option::InputClass) {
@@ -240,7 +241,7 @@ void SYCL::fpga::BackendCompiler::ConstructJob(Compilation &C,
240241
types::ID Ty = getToolChain().LookupTypeForExtension(Ext.drop_front());
241242
if (Ty == types::TY_INVALID)
242243
continue;
243-
if (types::isSrcFile(Ty) || Ty == types::TY_Object) {
244+
if (types::isSrcFile(Ty)) {
244245
llvm::sys::path::replace_extension(FN, "d");
245246
FPGADepFiles.push_back(InputInfo(types::TY_Dependencies,
246247
Args.MakeArgString(FN), Args.MakeArgString(FN)));

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,8 @@ static bool IsSyclMathFunc(unsigned BuiltinID) {
138138
case Builtin::BI__builtin_truncl:
139139
case Builtin::BIlroundl:
140140
case Builtin::BI__builtin_lroundl:
141-
case Builtin::BIceil:
142-
case Builtin::BI__builtin_ceil:
143141
case Builtin::BIcopysign:
144142
case Builtin::BI__builtin_copysign:
145-
case Builtin::BIfabs:
146-
case Builtin::BI__builtin_fabs:
147143
case Builtin::BIfloor:
148144
case Builtin::BI__builtin_floor:
149145
case Builtin::BIfmax:
@@ -158,12 +154,8 @@ static bool IsSyclMathFunc(unsigned BuiltinID) {
158154
case Builtin::BI__builtin_round:
159155
case Builtin::BItrunc:
160156
case Builtin::BI__builtin_trunc:
161-
case Builtin::BIceilf:
162-
case Builtin::BI__builtin_ceilf:
163157
case Builtin::BIcopysignf:
164158
case Builtin::BI__builtin_copysignf:
165-
case Builtin::BIfabsf:
166-
case Builtin::BI__builtin_fabsf:
167159
case Builtin::BIfloorf:
168160
case Builtin::BI__builtin_floorf:
169161
case Builtin::BIfmaxf:
@@ -215,6 +207,8 @@ class MarkDeviceFunction : public RecursiveASTVisitor<MarkDeviceFunction> {
215207

216208
if (FunctionDecl *Callee = e->getDirectCallee()) {
217209
Callee = Callee->getCanonicalDecl();
210+
assert(Callee && "Device function canonical decl must be available");
211+
218212
// Remember that all SYCL kernel functions have deferred
219213
// instantiation as template functions. It means that
220214
// all functions used by kernel have already been parsed and have
@@ -254,7 +248,7 @@ class MarkDeviceFunction : public RecursiveASTVisitor<MarkDeviceFunction> {
254248
}
255249
// Specifically check if the math library function corresponding to this
256250
// builtin is supported for SYCL
257-
unsigned BuiltinID = (Callee ? Callee->getBuiltinID() : 0);
251+
unsigned BuiltinID = Callee->getBuiltinID();
258252
if (BuiltinID && !IsSyclMathFunc(BuiltinID)) {
259253
StringRef Name = SemaRef.Context.BuiltinInfo.getName(BuiltinID);
260254
SemaRef.Diag(e->getExprLoc(), diag::err_builtin_target_unsupported)

clang/lib/Sema/SemaType.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2344,6 +2344,12 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM,
23442344
<< ArraySize->getSourceRange();
23452345
ASM = ArrayType::Normal;
23462346
}
2347+
2348+
// Zero length arrays are disallowed in SYCL device code.
2349+
if (getLangOpts().SYCLIsDevice)
2350+
SYCLDiagIfDeviceCode(ArraySize->getBeginLoc(),
2351+
diag::err_typecheck_zero_array_size)
2352+
<< ArraySize->getSourceRange();
23472353
} else if (!T->isDependentType() && !T->isVariablyModifiedType() &&
23482354
!T->isIncompleteType() && !T->isUndeducedType()) {
23492355
// Is the array too large?

0 commit comments

Comments
 (0)