Skip to content

Commit 615f770

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents b9a6376 + 8083f8a commit 615f770

File tree

87 files changed

+1343
-399
lines changed

Some content is hidden

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

87 files changed

+1343
-399
lines changed

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ def err_drv_no_cuda_libdevice : Error<
6565
"via '--cuda-path', or pass '-nocudalib' to build without linking with "
6666
"libdevice">;
6767

68-
def warn_function_fp_accuracy_already_set : Warning <
69-
"floating point accuracy value of '%0' has already been assigned to "
70-
"function '%1'">,
71-
InGroup<DiagGroup<"fp-accuracy-already-set">>;
68+
def warn_drv_fp_accuracy_override : Warning <
69+
"'-ffp-accuracy=%0' overrides '-ffp-accuracy=%1' for the function '%2'">,
70+
InGroup<FPAccOverride>;
71+
7272
def err_drv_no_rocm_device_lib : Error<
7373
"cannot find ROCm device library%select{| for %1|for ABI version %1}0; provide its path via "
7474
"'--rocm-path' or '--rocm-device-lib-path', or pass '-nogpulib' to build "

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,7 @@ def DeallocInCategory:DiagGroup<"dealloc-in-category">;
850850
def SelectorTypeMismatch : DiagGroup<"selector-type-mismatch">;
851851
def Selector : DiagGroup<"selector", [SelectorTypeMismatch]>;
852852
def Protocol : DiagGroup<"protocol">;
853+
def FPAccOverride : DiagGroup<"fp-accuracy-override">;
853854
// No longer in use, preserve for backwards compatibility.
854855
def : DiagGroup<"at-protocol">;
855856
def PropertyAccessDotSyntax: DiagGroup<"property-access-dot-syntax">;

clang/lib/CodeGen/CGLoopInfo.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,9 @@ MDNode *LoopInfo::createMetadata(
628628
Metadata *Vals[] = {MDString::get(Ctx, "llvm.loop.intel.pipelining.enable"),
629629
ConstantAsMetadata::get(
630630
ConstantInt::get(llvm::Type::getInt32Ty(Ctx), 1))};
631+
LoopProperties.push_back(MDNode::get(Ctx, Vals));
631632
}
633+
632634
// Setting clang::code_align attribute.
633635
if (Attrs.CodeAlign > 0) {
634636
Metadata *Vals[] = {MDString::get(Ctx, "llvm.loop.align"),

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2127,7 +2127,8 @@ void CodeGenModule::EmitCtorList(CtorList &Fns, const char *GlobalName) {
21272127
ctor.addInt(Int32Ty, I.Priority);
21282128
ctor.add(I.Initializer);
21292129
if (I.AssociatedData)
2130-
ctor.add(I.AssociatedData);
2130+
ctor.add(llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
2131+
I.AssociatedData, TargetType));
21312132
else
21322133
ctor.addNullPointer(TargetType);
21332134
ctor.finishAndAddTo(ctors);

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5482,7 +5482,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
54825482
Triple.getSubArch() == llvm::Triple::SPIRSubArch_gen) ||
54835483
Triple.isNVPTX() || Triple.isAMDGCN()) {
54845484
StringRef Device = JA.getOffloadingArch();
5485-
if (!Device.empty()) {
5485+
if (!Device.empty() && !SYCL::gen::getGenDeviceMacro(Device).empty()) {
54865486
Macro = "-D";
54875487
Macro += SYCL::gen::getGenDeviceMacro(Device);
54885488
}
@@ -9792,7 +9792,8 @@ void OffloadWrapper::ConstructJob(Compilation &C, const JobAction &JA,
97929792
if (TC.getTriple().getSubArch() == llvm::Triple::NoSubArch) {
97939793
// Only store compile/link opts in the image descriptor for the SPIR-V
97949794
// target; AOT compilation has already been performed otherwise.
9795-
TC.AddImpliedTargetArgs(TT, TCArgs, BuildArgs, JA);
9795+
const ToolChain *HostTC = C.getSingleOffloadToolChain<Action::OFK_Host>();
9796+
TC.AddImpliedTargetArgs(TT, TCArgs, BuildArgs, JA, *HostTC);
97969797
TC.TranslateBackendTargetArgs(TT, TCArgs, BuildArgs);
97979798
createArgString("-compile-opts=");
97989799
BuildArgs.clear();

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,9 @@ void SYCL::fpga::BackendCompiler::constructOpenCLAOTCommand(
593593
// Add any implied arguments before user defined arguments.
594594
const toolchains::SYCLToolChain &TC =
595595
static_cast<const toolchains::SYCLToolChain &>(getToolChain());
596+
const ToolChain *HostTC = C.getSingleOffloadToolChain<Action::OFK_Host>();
596597
llvm::Triple CPUTriple("spir64_x86_64");
597-
TC.AddImpliedTargetArgs(CPUTriple, Args, CmdArgs, JA);
598+
TC.AddImpliedTargetArgs(CPUTriple, Args, CmdArgs, JA, *HostTC);
598599
// Add the target args passed in
599600
TC.TranslateBackendTargetArgs(CPUTriple, Args, CmdArgs);
600601
TC.TranslateLinkerTargetArgs(CPUTriple, Args, CmdArgs);
@@ -751,7 +752,9 @@ void SYCL::fpga::BackendCompiler::ConstructJob(
751752
Twine("-output-report-folder=") + ReportOptArg));
752753

753754
// Add any implied arguments before user defined arguments.
754-
TC.AddImpliedTargetArgs(getToolChain().getTriple(), Args, CmdArgs, JA);
755+
const ToolChain *HostTC = C.getSingleOffloadToolChain<Action::OFK_Host>();
756+
TC.AddImpliedTargetArgs(getToolChain().getTriple(), Args, CmdArgs, JA,
757+
*HostTC);
755758

756759
// Add -Xsycl-target* options.
757760
TC.TranslateBackendTargetArgs(getToolChain().getTriple(), Args, CmdArgs);
@@ -812,7 +815,9 @@ void SYCL::gen::BackendCompiler::ConstructJob(Compilation &C,
812815
// Add -Xsycl-target* options.
813816
const toolchains::SYCLToolChain &TC =
814817
static_cast<const toolchains::SYCLToolChain &>(getToolChain());
815-
TC.AddImpliedTargetArgs(getToolChain().getTriple(), Args, CmdArgs, JA);
818+
const ToolChain *HostTC = C.getSingleOffloadToolChain<Action::OFK_Host>();
819+
TC.AddImpliedTargetArgs(getToolChain().getTriple(), Args, CmdArgs, JA,
820+
*HostTC);
816821
TC.TranslateBackendTargetArgs(getToolChain().getTriple(), Args, CmdArgs,
817822
Device);
818823
TC.TranslateLinkerTargetArgs(getToolChain().getTriple(), Args, CmdArgs);
@@ -981,8 +986,9 @@ void SYCL::x86_64::BackendCompiler::ConstructJob(
981986
// Add -Xsycl-target* options.
982987
const toolchains::SYCLToolChain &TC =
983988
static_cast<const toolchains::SYCLToolChain &>(getToolChain());
984-
985-
TC.AddImpliedTargetArgs(getToolChain().getTriple(), Args, CmdArgs, JA);
989+
const ToolChain *HostTC = C.getSingleOffloadToolChain<Action::OFK_Host>();
990+
TC.AddImpliedTargetArgs(getToolChain().getTriple(), Args, CmdArgs, JA,
991+
*HostTC);
986992
TC.TranslateBackendTargetArgs(getToolChain().getTriple(), Args, CmdArgs);
987993
TC.TranslateLinkerTargetArgs(getToolChain().getTriple(), Args, CmdArgs);
988994
SmallString<128> ExecPath(
@@ -1146,7 +1152,8 @@ void SYCLToolChain::TranslateTargetOpt(const llvm::opt::ArgList &Args,
11461152
void SYCLToolChain::AddImpliedTargetArgs(const llvm::Triple &Triple,
11471153
const llvm::opt::ArgList &Args,
11481154
llvm::opt::ArgStringList &CmdArgs,
1149-
const JobAction &JA) const {
1155+
const JobAction &JA,
1156+
const ToolChain &HostTC) const {
11501157
// Current implied args are for debug information and disabling of
11511158
// optimizations. They are passed along to the respective areas as follows:
11521159
// FPGA: -g -cl-opt-disable
@@ -1201,6 +1208,19 @@ void SYCLToolChain::AddImpliedTargetArgs(const llvm::Triple &Triple,
12011208
RegAllocModeVal.split(RegAllocModeArgs, ',');
12021209
for (StringRef Elem : RegAllocModeArgs)
12031210
ProcessElement(Elem);
1211+
} else if (!HostTC.getTriple().isWindowsMSVCEnvironment()) {
1212+
// If -ftarget-register-alloc-mode is not specified, the default is
1213+
// pvc:default on Windows and and pvc:auto otherwise.
1214+
StringRef DeviceName = "pvc";
1215+
StringRef BackendOptName = SYCL::gen::getGenGRFFlag("auto");
1216+
if (IsGen)
1217+
PerDeviceArgs.push_back(
1218+
{DeviceName, Args.MakeArgString("-options " + BackendOptName)});
1219+
else if (Triple.isSPIR() &&
1220+
Triple.getSubArch() == llvm::Triple::NoSubArch) {
1221+
BeArgs.push_back(Args.MakeArgString(RegAllocModeOptName + DeviceName +
1222+
":" + BackendOptName));
1223+
}
12041224
}
12051225
if (IsGen) {
12061226
// For GEN (spir64_gen) we have implied -device settings given usage

clang/lib/Driver/ToolChains/SYCL.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class LLVM_LIBRARY_VISIBILITY SYCLToolChain : public ToolChain {
173173
void AddImpliedTargetArgs(const llvm::Triple &Triple,
174174
const llvm::opt::ArgList &Args,
175175
llvm::opt::ArgStringList &CmdArgs,
176-
const JobAction &JA) const;
176+
const JobAction &JA, const ToolChain &HostTC) const;
177177
void TranslateBackendTargetArgs(const llvm::Triple &Triple,
178178
const llvm::opt::ArgList &Args,
179179
llvm::opt::ArgStringList &CmdArgs,

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -599,12 +599,6 @@ static bool FixupInvocation(CompilerInvocation &Invocation,
599599
LangOpts.NewAlignOverride = 0;
600600
}
601601

602-
// Diagnose FPAccuracy option validity.
603-
if (!LangOpts.FPAccuracyVal.empty())
604-
for (const auto &F : LangOpts.FPAccuracyFuncMap)
605-
Diags.Report(diag::warn_function_fp_accuracy_already_set)
606-
<< F.second << F.first;
607-
608602
// Prevent the user from specifying both -fsycl-is-device and -fsycl-is-host.
609603
if (LangOpts.SYCLIsDevice && LangOpts.SYCLIsHost)
610604
Diags.Report(diag::err_drv_argument_not_allowed_with) << "-fsycl-is-device"
@@ -3728,6 +3722,12 @@ static void checkFPAccuracyIsValid(StringRef ValElement,
37283722
<< "-ffp-accuracy" << ValElement;
37293723
}
37303724

3725+
static void diagnoseFPAccuracyHasVal(DiagnosticsEngine &Diags,
3726+
StringRef ValElement, StringRef Opt1,
3727+
StringRef Opt2, const std::string Func) {
3728+
Diags.Report(diag::warn_drv_fp_accuracy_override) << Opt1 << Opt2 << Func;
3729+
}
3730+
37313731
void CompilerInvocation::ParseFpAccuracyArgs(LangOptions &Opts, ArgList &Args,
37323732
DiagnosticsEngine &Diags) {
37333733
for (StringRef Values : Args.getAllArgValues(OPT_ffp_builtin_accuracy_EQ)) {
@@ -3743,6 +3743,14 @@ void CompilerInvocation::ParseFpAccuracyArgs(LangOptions &Opts, ArgList &Args,
37433743
if (ValElement.size() == 1) {
37443744
checkFPAccuracyIsValid(ValElement[0], Diags);
37453745
Opts.FPAccuracyVal = ValElement[0].str();
3746+
// if FPAccuracyFuncMap is not empty, visit it and update
3747+
// the values of the FPAccuracy of each function in the map;
3748+
// last fp-accuracy option in the command line wins.
3749+
for (auto &F : Opts.FPAccuracyFuncMap) {
3750+
diagnoseFPAccuracyHasVal(Diags, ValElement[0], ValuesArr[1],
3751+
ValuesArr[0], F.first);
3752+
F.second = ValElement[0];
3753+
}
37463754
}
37473755
// The option is of the form -ffp-accuracy=value:[f1, ... fn].
37483756
if (ValElement.size() == 2) {
@@ -3753,13 +3761,23 @@ void CompilerInvocation::ParseFpAccuracyArgs(LangOptions &Opts, ArgList &Args,
37533761
FuncName = FuncName.drop_front(1);
37543762
if (FuncName.back() == ']')
37553763
FuncName = FuncName.drop_back(1);
3756-
auto FuncMap = Opts.FPAccuracyFuncMap.find(FuncName.str());
37573764
checkFPAccuracyIsValid(ValElement[0], Diags);
37583765
// No need to fill the map if the FPaccuracy is 'default'.
37593766
// The default builtin will be generated.
3760-
if (!ValElement[0].equals("default"))
3761-
Opts.FPAccuracyFuncMap.insert(
3762-
{FuncName.str(), ValElement[0].str()});
3767+
if (!ValElement[0].equals("default")) {
3768+
// if FPAccuracyFuncMap of this function has been previously set
3769+
// update its value; the last fp-accuracy option in the command
3770+
// line wins.
3771+
auto FuncMap = Opts.FPAccuracyFuncMap.find(FuncName.str());
3772+
if (FuncMap != Opts.FPAccuracyFuncMap.end()) {
3773+
diagnoseFPAccuracyHasVal(Diags, ValElement[0], ValuesArr[1],
3774+
ValuesArr[0], FuncMap->first.c_str());
3775+
FuncMap->second = ValElement[0].str();
3776+
} else {
3777+
Opts.FPAccuracyFuncMap.insert(
3778+
{FuncName.str(), ValElement[0].str()});
3779+
}
3780+
}
37633781
}
37643782
}
37653783
}

clang/lib/Sema/SemaAvailability.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,8 @@ static void DoEmitAvailabilityWarning(Sema &S, AvailabilityResult K,
544544
S.getTopMostPointOfInstantiation(ReferringDecl);
545545
bool ShouldAllowWarningInSystemHeader =
546546
InstantiationLoc != Loc &&
547-
!S.getSourceManager().isInSystemHeader(InstantiationLoc);
547+
!S.getSourceManager().isInSystemHeader(InstantiationLoc) &&
548+
!S.getLangOpts().SYCLIsDevice && !S.getLangOpts().SYCLIsHost;
548549
struct AllowWarningInSystemHeaders {
549550
AllowWarningInSystemHeaders(DiagnosticsEngine &E,
550551
bool AllowWarningInSystemHeaders)

clang/lib/Sema/SemaStmtAttr.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,7 @@ void Sema::ProcessStmtAttributes(Stmt *S, const ParsedAttributes &InAttrs,
11531153

11541154
bool Sema::CheckRebuiltAttributedStmtAttributes(ArrayRef<const Attr *> Attrs) {
11551155
CheckRedundantSYCLIntelIVDepAttrs(*this, Attrs);
1156+
return false;
11561157
}
11571158

11581159
bool Sema::CheckRebuiltCodeAlignStmtAttributes(ArrayRef<const Attr *> Attrs) {

0 commit comments

Comments
 (0)