Skip to content

Commit 6649012

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web' (intel#19)
2 parents 13de58e + 4a78734 commit 6649012

File tree

71 files changed

+758
-331
lines changed

Some content is hidden

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

71 files changed

+758
-331
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ opencl-aot/ @dm-vodopyanov @AlexeySachkov @romanovvlad
1515
# Device library
1616
libdevice/ @vzakhari
1717

18+
# DPC++ runtime library
19+
sycl/ @intel/llvm-reviewers-runtime
20+
1821
# Documentation
1922
sycl/ReleaseNotes.md @pvchupin
2023
sycl/doc/ @pvchupin @kbobrovs
2124
sycl/doc/extensions/ @intel/dpcpp-specification-reviewers
2225

23-
# DPC++ runtime library
24-
sycl/ @intel/llvm-reviewers-runtime
25-
2626
# USM
2727
sycl/include/CL/sycl/detail/clusm.hpp @jbrodman
2828
sycl/include/CL/sycl/detail/usm_impl.hpp @jbrodman

.github/workflows/clang-format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
- name: Run clang-format for the patch
2020
run: |
21-
git diff -U0 --no-color ${GITHUB_SHA}^1 ${GITHUB_SHA} -- | ./clang/tools/clang-format/clang-format-diff.py -p1 -binary clang-format-9 > ./clang-format.patch
21+
git diff --no-color ${GITHUB_SHA}^1 ${GITHUB_SHA} --name-only -- | grep -v "/test/" | xargs git diff -U0 --no-color ${GITHUB_SHA}^1 ${GITHUB_SHA} -- | ./clang/tools/clang-format/clang-format-diff.py -p1 -binary clang-format-9 > ./clang-format.patch
2222
2323
# Add patch with formatting fixes to CI job artifacts
2424
- uses: actions/upload-artifact@v1

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
Intel staging area for llvm.org contribution.
66
Home for Intel LLVM-based projects:
77

8-
* oneAPI Data Parallel C++ compiler - see **sycl** branch. More information on
9-
oneAPI and DPC++ is available at
10-
[https://www.oneapi.com/](https://www.oneapi.com/)
8+
* oneAPI Data Parallel C++ compiler - see
9+
[sycl](https://github.com/intel/llvm/tree/sycl) branch. More information on
10+
oneAPI and DPC++ is available at
11+
[https://www.oneapi.com/](https://www.oneapi.com/)
1112
* [![Linux Post Commit Checks](https://github.com/intel/llvm/workflows/Linux%20Post%20Commit%20Checks/badge.svg)](https://github.com/intel/llvm/actions?query=workflow%3A%22Linux+Post+Commit+Checks%22)
1213
[![Generate Doxygen documentation](https://github.com/intel/llvm/workflows/Generate%20Doxygen%20documentation/badge.svg)](https://github.com/intel/llvm/actions?query=workflow%3A%22Generate+Doxygen+documentation%22)
14+
* Late-outline OpenMP\* and OpenMP\* Offload - see
15+
[openmp](https://github.com/intel/llvm/tree/openmp) branch.
1316

1417
## License
1518

@@ -23,11 +26,12 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
2326

2427
* oneAPI Data Parallel C++ compiler - See
2528
[DPC++ Documentation](https://intel.github.io/llvm-docs/)
29+
* Late-outline OpenMP\* and OpenMP\* Offload - TBD
2630

2731
## DPC++ extensions
2832

2933
DPC++ is an open, cross-architecture language built upon the ISO C++ and Khronos
3034
SYCL\* standards. DPC++ extends these standards with a number of extensions,
3135
which can be found in [sycl/doc/extensions](sycl/doc/extensions) directory.
3236

33-
\*Other names and brands may be claimed as the property of others.
37+
*\*Other names and brands may be claimed as the property of others.*

clang/include/clang/Driver/Options.td

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ def Wno_nonportable_cfstrings : Joined<["-"], "Wno-nonportable-cfstrings">, Grou
725725
Flags<[CC1Option]>;
726726
def Wnonportable_cfstrings : Joined<["-"], "Wnonportable-cfstrings">, Group<W_Group>,
727727
Flags<[CC1Option]>;
728-
def Wno_sycl_strict : Joined<["-"], "Wno-sycl-strict">, Group<W_Group>, HelpText<"Disable warnings which enforce strict SYCL language compatibility.">;
728+
def Wno_sycl_strict : Flag<["-"], "Wno-sycl-strict">, Group<W_Group>, HelpText<"Disable warnings which enforce strict SYCL language compatibility.">;
729729
def Wp_COMMA : CommaJoined<["-"], "Wp,">,
730730
HelpText<"Pass the comma separated arguments in <arg> to the preprocessor">,
731731
MetaVarName<"<arg>">, Group<Preprocessor_Group>;
@@ -2402,6 +2402,10 @@ def fsycl_device_code_split_esimd : Flag<["-"], "fsycl-device-code-split-esimd">
24022402
Flags<[CC1Option, CoreOption]>, HelpText<"Split SYCL and ESIMD kernels into separate modules">;
24032403
def fno_sycl_device_code_split_esimd : Flag<["-"], "fno-sycl-device-code-split-esimd">,
24042404
Flags<[CC1Option, CoreOption]>, HelpText<"Don't split SYCL and ESIMD kernels into separate modules">;
2405+
def fsycl_device_code_lower_esimd : Flag<["-"], "fsycl-device-code-lower-esimd">,
2406+
Flags<[CC1Option, CoreOption]>, HelpText<"Lower ESIMD-specific constructs">;
2407+
def fno_sycl_device_code_lower_esimd : Flag<["-"], "fno-sycl-device-code-lower-esimd">,
2408+
Flags<[CC1Option, CoreOption]>, HelpText<"Do not lower ESIMD-specific constructs">;
24052409
defm sycl_id_queries_fit_in_int: OptInFFlag<"sycl-id-queries-fit-in-int", "Assume", "Do not assume", " that SYCL ID queries fit within MAX_INT.", [CC1Option,CoreOption], LangOpts<"SYCLValueFitInMaxInt">>;
24062410
def fsycl_use_bitcode : Flag<["-"], "fsycl-use-bitcode">,
24072411
Flags<[CC1Option, CoreOption]>, HelpText<"Use LLVM bitcode instead of SPIR-V in fat objects">;

clang/include/clang/Sema/Sema.h

Lines changed: 34 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -13068,14 +13068,12 @@ void Sema::addIntelSYCLSingleArgFunctionAttr(Decl *D,
1306813068
assert(E && "Attribute must have an argument.");
1306913069

1307013070
if (!E->isInstantiationDependent()) {
13071-
Optional<llvm::APSInt> ArgVal = E->getIntegerConstantExpr(getASTContext());
13072-
if (!ArgVal) {
13073-
Diag(E->getExprLoc(), diag::err_attribute_argument_type)
13074-
<< CI.getAttrName() << AANT_ArgumentIntegerConstant
13075-
<< E->getSourceRange();
13071+
llvm::APSInt ArgVal;
13072+
ExprResult ICE = VerifyIntegerConstantExpression(E, &ArgVal);
13073+
if (ICE.isInvalid())
1307613074
return;
13077-
}
13078-
int32_t ArgInt = ArgVal->getSExtValue();
13075+
E = ICE.get();
13076+
int32_t ArgInt = ArgVal.getSExtValue();
1307913077
if (CI.getParsedKind() == ParsedAttr::AT_SYCLIntelNumSimdWorkItems ||
1308013078
CI.getParsedKind() == ParsedAttr::AT_IntelReqdSubGroupSize) {
1308113079
if (ArgInt <= 0) {
@@ -13101,77 +13099,59 @@ void Sema::addIntelSYCLSingleArgFunctionAttr(Decl *D,
1310113099
D->addAttr(::new (Context) AttrType(Context, CI, E));
1310213100
}
1310313101

13104-
template <typename AttrInfo>
13105-
static bool handleMaxWorkSizeAttrExpr(Sema &S, const AttrInfo &AI,
13106-
const Expr *E, unsigned &Val,
13107-
unsigned Idx) {
13102+
static Expr *checkMaxWorkSizeAttrExpr(Sema &S, const AttributeCommonInfo &CI,
13103+
Expr *E) {
1310813104
assert(E && "Attribute must have an argument.");
1310913105

1311013106
if (!E->isInstantiationDependent()) {
13111-
Optional<llvm::APSInt> ArgVal =
13112-
E->getIntegerConstantExpr(S.getASTContext());
13107+
llvm::APSInt ArgVal;
13108+
ExprResult ICE = S.VerifyIntegerConstantExpression(E, &ArgVal);
1311313109

13114-
if (!ArgVal) {
13115-
S.Diag(AI.getLocation(), diag::err_attribute_argument_type)
13116-
<< &AI << AANT_ArgumentIntegerConstant << E->getSourceRange();
13117-
return false;
13118-
}
13110+
if (ICE.isInvalid())
13111+
return nullptr;
13112+
13113+
E = ICE.get();
1311913114

13120-
if (ArgVal->isNegative()) {
13115+
if (ArgVal.isNegative()) {
1312113116
S.Diag(E->getExprLoc(),
1312213117
diag::warn_attribute_requires_non_negative_integer_argument)
1312313118
<< E->getType() << S.Context.UnsignedLongLongTy
1312413119
<< E->getSourceRange();
13125-
return true;
13120+
return E;
1312613121
}
1312713122

13128-
Val = ArgVal->getZExtValue();
13123+
unsigned Val = ArgVal.getZExtValue();
1312913124
if (Val == 0) {
1313013125
S.Diag(E->getExprLoc(), diag::err_attribute_argument_is_zero)
13131-
<< &AI << E->getSourceRange();
13132-
return false;
13126+
<< CI << E->getSourceRange();
13127+
return nullptr;
1313313128
}
1313413129
}
13135-
return true;
13136-
}
13137-
13138-
template <typename AttrType>
13139-
static bool checkMaxWorkSizeAttrArguments(Sema &S, Expr *XDimExpr,
13140-
Expr *YDimExpr, Expr *ZDimExpr,
13141-
const AttrType &Attr) {
13142-
// Accept template arguments for now as they depend on something else.
13143-
// We'll get to check them when they eventually get instantiated.
13144-
if (XDimExpr->isValueDependent() ||
13145-
(YDimExpr && YDimExpr->isValueDependent()) ||
13146-
(ZDimExpr && ZDimExpr->isValueDependent()))
13147-
return false;
13148-
13149-
unsigned XDim = 0;
13150-
if (!handleMaxWorkSizeAttrExpr(S, Attr, XDimExpr, XDim, 0))
13151-
return true;
13152-
13153-
unsigned YDim = 0;
13154-
if (YDimExpr && !handleMaxWorkSizeAttrExpr(S, Attr, YDimExpr, YDim, 1))
13155-
return true;
13156-
13157-
unsigned ZDim = 0;
13158-
if (ZDimExpr && !handleMaxWorkSizeAttrExpr(S, Attr, ZDimExpr, ZDim, 2))
13159-
return true;
13160-
13161-
return false;
13130+
return E;
1316213131
}
1316313132

1316413133
template <typename WorkGroupAttrType>
1316513134
void Sema::addIntelSYCLTripleArgFunctionAttr(Decl *D,
1316613135
const AttributeCommonInfo &CI,
1316713136
Expr *XDimExpr, Expr *YDimExpr,
1316813137
Expr *ZDimExpr) {
13169-
WorkGroupAttrType TmpAttr(Context, CI, XDimExpr, YDimExpr, ZDimExpr);
1317013138

13171-
if (checkMaxWorkSizeAttrArguments(*this, XDimExpr, YDimExpr, ZDimExpr,
13172-
TmpAttr))
13173-
return;
13139+
assert((XDimExpr && YDimExpr && ZDimExpr) &&
13140+
"argument has unexpected null value");
13141+
13142+
// Accept template arguments for now as they depend on something else.
13143+
// We'll get to check them when they eventually get instantiated.
13144+
if (!XDimExpr->isValueDependent() && !YDimExpr->isValueDependent() &&
13145+
!ZDimExpr->isValueDependent()) {
13146+
13147+
// Save ConstantExpr in semantic attribute
13148+
XDimExpr = checkMaxWorkSizeAttrExpr(*this, CI, XDimExpr);
13149+
YDimExpr = checkMaxWorkSizeAttrExpr(*this, CI, YDimExpr);
13150+
ZDimExpr = checkMaxWorkSizeAttrExpr(*this, CI, ZDimExpr);
1317413151

13152+
if (!XDimExpr || !YDimExpr || !ZDimExpr)
13153+
return;
13154+
}
1317513155
D->addAttr(::new (Context)
1317613156
WorkGroupAttrType(Context, CI, XDimExpr, YDimExpr, ZDimExpr));
1317713157
}

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,6 @@ void CodeGenFunction::EmitOpenCLKernelMetadata(const FunctionDecl *FD,
620620
}
621621

622622
if (const ReqdWorkGroupSizeAttr *A = FD->getAttr<ReqdWorkGroupSizeAttr>()) {
623-
llvm::LLVMContext &Context = getLLVMContext();
624623
ASTContext &ClangCtx = FD->getASTContext();
625624
Optional<llvm::APSInt> XDimVal = A->getXDimVal(ClangCtx);
626625
Optional<llvm::APSInt> YDimVal = A->getYDimVal(ClangCtx);
@@ -643,10 +642,9 @@ void CodeGenFunction::EmitOpenCLKernelMetadata(const FunctionDecl *FD,
643642

644643
if (const IntelReqdSubGroupSizeAttr *A =
645644
FD->getAttr<IntelReqdSubGroupSizeAttr>()) {
646-
llvm::LLVMContext &Context = getLLVMContext();
647-
Optional<llvm::APSInt> ArgVal =
648-
A->getValue()->getIntegerConstantExpr(FD->getASTContext());
649-
assert(ArgVal.hasValue() && "Not an integer constant expression");
645+
const auto *CE = dyn_cast<ConstantExpr>(A->getValue());
646+
assert(CE && "Not an integer constant expression");
647+
Optional<llvm::APSInt> ArgVal = CE->getResultAsAPSInt();
650648
llvm::Metadata *AttrMDArgs[] = {llvm::ConstantAsMetadata::get(
651649
Builder.getInt32(ArgVal->getSExtValue()))};
652650
Fn->setMetadata("intel_reqd_sub_group_size",
@@ -663,10 +661,9 @@ void CodeGenFunction::EmitOpenCLKernelMetadata(const FunctionDecl *FD,
663661

664662
if (const SYCLIntelNumSimdWorkItemsAttr *A =
665663
FD->getAttr<SYCLIntelNumSimdWorkItemsAttr>()) {
666-
llvm::LLVMContext &Context = getLLVMContext();
667-
Optional<llvm::APSInt> ArgVal =
668-
A->getValue()->getIntegerConstantExpr(FD->getASTContext());
669-
assert(ArgVal.hasValue() && "Not an integer constant expression");
664+
const auto *CE = dyn_cast<ConstantExpr>(A->getValue());
665+
assert(CE && "Not an integer constant expression");
666+
Optional<llvm::APSInt> ArgVal = CE->getResultAsAPSInt();
670667
llvm::Metadata *AttrMDArgs[] = {llvm::ConstantAsMetadata::get(
671668
Builder.getInt32(ArgVal->getSExtValue()))};
672669
Fn->setMetadata("num_simd_work_items",
@@ -675,9 +672,9 @@ void CodeGenFunction::EmitOpenCLKernelMetadata(const FunctionDecl *FD,
675672

676673
if (const SYCLIntelSchedulerTargetFmaxMhzAttr *A =
677674
FD->getAttr<SYCLIntelSchedulerTargetFmaxMhzAttr>()) {
678-
Optional<llvm::APSInt> ArgVal =
679-
A->getValue()->getIntegerConstantExpr(FD->getASTContext());
680-
assert(ArgVal.hasValue() && "Not an integer constant expression");
675+
const auto *CE = dyn_cast<ConstantExpr>(A->getValue());
676+
assert(CE && "Not an integer constant expression");
677+
Optional<llvm::APSInt> ArgVal = CE->getResultAsAPSInt();
681678
llvm::Metadata *AttrMDArgs[] = {llvm::ConstantAsMetadata::get(
682679
Builder.getInt32(ArgVal->getSExtValue()))};
683680
Fn->setMetadata("scheduler_target_fmax_mhz",
@@ -686,10 +683,9 @@ void CodeGenFunction::EmitOpenCLKernelMetadata(const FunctionDecl *FD,
686683

687684
if (const SYCLIntelMaxGlobalWorkDimAttr *A =
688685
FD->getAttr<SYCLIntelMaxGlobalWorkDimAttr>()) {
689-
llvm::LLVMContext &Context = getLLVMContext();
690-
Optional<llvm::APSInt> ArgVal =
691-
A->getValue()->getIntegerConstantExpr(FD->getASTContext());
692-
assert(ArgVal.hasValue() && "Not an integer constant expression");
686+
const auto *CE = dyn_cast<ConstantExpr>(A->getValue());
687+
assert(CE && "Not an integer constant expression");
688+
Optional<llvm::APSInt> ArgVal = CE->getResultAsAPSInt();
693689
llvm::Metadata *AttrMDArgs[] = {llvm::ConstantAsMetadata::get(
694690
Builder.getInt32(ArgVal->getSExtValue()))};
695691
Fn->setMetadata("max_global_work_dim",
@@ -698,7 +694,6 @@ void CodeGenFunction::EmitOpenCLKernelMetadata(const FunctionDecl *FD,
698694

699695
if (const SYCLIntelMaxWorkGroupSizeAttr *A =
700696
FD->getAttr<SYCLIntelMaxWorkGroupSizeAttr>()) {
701-
llvm::LLVMContext &Context = getLLVMContext();
702697
ASTContext &ClangCtx = FD->getASTContext();
703698
Optional<llvm::APSInt> XDimVal = A->getXDimVal(ClangCtx);
704699
Optional<llvm::APSInt> YDimVal = A->getYDimVal(ClangCtx);
@@ -723,9 +718,9 @@ void CodeGenFunction::EmitOpenCLKernelMetadata(const FunctionDecl *FD,
723718
FD->getAttr<SYCLIntelNoGlobalWorkOffsetAttr>()) {
724719
const Expr *Arg = A->getValue();
725720
assert(Arg && "Got an unexpected null argument");
726-
Optional<llvm::APSInt> ArgVal =
727-
Arg->getIntegerConstantExpr(FD->getASTContext());
728-
assert(ArgVal.hasValue() && "Not an integer constant expression");
721+
const auto *CE = dyn_cast<ConstantExpr>(Arg);
722+
assert(CE && "Not an integer constant expression");
723+
Optional<llvm::APSInt> ArgVal = CE->getResultAsAPSInt();
729724
if (ArgVal->getBoolValue())
730725
Fn->setMetadata("no_global_work_offset", llvm::MDNode::get(Context, {}));
731726
}

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5049,8 +5049,8 @@ void CodeGenModule::EmitAliasDefinition(GlobalDecl GD) {
50495049
LT = getFunctionLinkage(GD);
50505050
AS = Aliasee->getType()->getPointerAddressSpace();
50515051
} else {
5052-
const auto *VarD = cast<VarDecl>(GD.getDecl());
5053-
AS = ArgInfoAddressSpace(GetGlobalVarAddressSpace(VarD));
5052+
AS = ArgInfoAddressSpace(
5053+
GetGlobalVarAddressSpace(dyn_cast<VarDecl>(GD.getDecl())));
50545054
Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(), DeclTy->getPointerTo(AS),
50555055
/*D=*/nullptr);
50565056
if (const auto *VD = dyn_cast<VarDecl>(GD.getDecl()))

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8308,6 +8308,9 @@ void SYCLPostLink::ConstructJob(Compilation &C, const JobAction &JA,
83088308
if (TCArgs.hasFlag(options::OPT_fsycl_device_code_split_esimd,
83098309
options::OPT_fno_sycl_device_code_split_esimd, true))
83108310
addArgs(CmdArgs, TCArgs, {"-split-esimd"});
8311+
if (TCArgs.hasFlag(options::OPT_fsycl_device_code_lower_esimd,
8312+
options::OPT_fno_sycl_device_code_lower_esimd, false))
8313+
addArgs(CmdArgs, TCArgs, {"-lower-esimd"});
83118314
}
83128315
// specialization constants processing is mandatory
83138316
auto *SYCLPostLink = llvm::dyn_cast<SYCLPostLinkJobAction>(&JA);

clang/lib/Sema/SemaExpr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16227,7 +16227,8 @@ Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
1622716227
if (Result)
1622816228
*Result = E->EvaluateKnownConstIntCheckOverflow(Context);
1622916229
if (!isa<ConstantExpr>(E))
16230-
E = ConstantExpr::Create(Context, E);
16230+
E = Result ? ConstantExpr::Create(Context, E, APValue(*Result))
16231+
: ConstantExpr::Create(Context, E);
1623116232
return E;
1623216233
}
1623316234

clang/test/AST/ast-dump-c-attr.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ struct [[deprecated]] Test4 {
3434
// CHECK-NEXT: FieldDecl{{.*}}Test6
3535
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:5, col:25> "Frobble" ""
3636
// CHECK-NEXT: FieldDecl{{.*}}Test7
37-
// CHECK-NEXT: Constant{{.*}}'int'
38-
// CHECK-NEXT: IntegerLiteral{{.*}}'int' 12
37+
// CHECK-NEXT: ConstantExpr{{.*}}'int'
38+
// CHECK-NEXT: value: Int 12
39+
// CHECK-NEXT: IntegerLiteral{{.*}}'int' 12
3940
// CHECK-NEXT: DeprecatedAttr 0x{{[^ ]*}} <col:15> "" ""
4041

4142
struct [[deprecated]] Test8;

0 commit comments

Comments
 (0)