Skip to content

Commit d768db6

Browse files
authored
Merge pull request #592 from tangjj11/SYCLomatic-20230213
[SYCLomatic] Fix sycl to SYCLomatic pull down failed.
2 parents 09f066f + 0f31f5d commit d768db6

File tree

217 files changed

+11973
-3761
lines changed

Some content is hidden

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

217 files changed

+11973
-3761
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
##SYCLomatic
2-
clang/ @oneapi-src/syclomatic-reviewers
2+
clang/ @oneapi-src/syclomatic-reviewers

.github/workflows/windows_test_comment_trigger.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,25 @@ jobs:
1010
if: ${{ github.event.issue.pull_request && github.event.comment.body == '/testwin' }}
1111
steps:
1212
- name: react_to_comment
13-
uses: actions/github-script@v4
13+
uses: actions/github-script@v6
1414
with:
1515
script: |
16-
const {owner, repo} = context.issue;
17-
github.reactions.createForIssueComment({
18-
owner,
19-
repo,
16+
github.rest.reactions.createForIssueComment({
17+
owner: context.issue.owner,
18+
repo: context.issue.repo,
2019
comment_id: context.payload.comment.id,
21-
content: "rocket",
20+
content: "rocket"
2221
});
2322
- name: get_pr_sha
2423
id: sha
25-
uses: actions/github-script@v4
24+
uses: actions/github-script@v6
2625
with:
2726
result-encoding: string
2827
script: |
29-
const { owner, repo, number } = context.issue;
30-
const pr = await github.pulls.get({
31-
owner,
32-
repo,
33-
pull_number: number,
28+
const pr = await github.rest.pulls.get({
29+
owner: context.issue.owner,
30+
repo: context.issue.repo,
31+
pull_number: number
3432
});
3533
return pr.data.head.sha
3634
- name: update_pr_status_pending

clang/include/clang/Basic/Attr.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,12 +1333,12 @@ def SYCLType: InheritableAttr {
13331333
"specialization_id", "kernel_handler", "buffer_location",
13341334
"no_alias", "accessor_property_list", "group",
13351335
"private_memory", "aspect", "annotated_ptr", "annotated_arg",
1336-
"stream", "sampler"],
1336+
"stream", "sampler", "host_pipe"],
13371337
["accessor", "local_accessor", "spec_constant",
13381338
"specialization_id", "kernel_handler", "buffer_location",
13391339
"no_alias", "accessor_property_list", "group",
13401340
"private_memory", "aspect", "annotated_ptr", "annotated_arg",
1341-
"stream", "sampler"]>];
1341+
"stream", "sampler", "host_pipe"]>];
13421342
// Only used internally by SYCL implementation
13431343
let Documentation = [InternalOnly];
13441344
}

clang/include/clang/Basic/CodeGenOptions.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,10 @@ CODEGENOPT(CtorDtorReturnThis, 1, 0)
515515
/// Whether to disable the standard optimization pipeline for the SYCL device compiler.
516516
CODEGENOPT(DisableSYCLEarlyOpts, 1, 0)
517517

518+
/// Optimize SYCL Framework functions. These are functions
519+
/// which do not contain "user" code.
520+
CODEGENOPT(OptimizeSYCLFramework, 1, 0)
521+
518522
#undef CODEGENOPT
519523
#undef ENUM_CODEGENOPT
520524
#undef VALUE_CODEGENOPT

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ def warn_drv_sycl_target_missing : Warning<
364364
InGroup<SyclTarget>;
365365
def err_drv_no_rdc_sycl_target_missing : Error<
366366
"linked binaries do not contain expected '%0' target; found targets: '%1', this is not supported with '-fno-sycl-rdc'">;
367+
def err_drv_fsycl_wrong_optimization_options : Error<
368+
"-fsycl-optimize-non-user-code option can be used only in conjunction with %0">;
367369
def err_drv_multiple_target_with_forced_target : Error<
368370
"multiple target usage with '%0' is not supported with '%1'">;
369371
def err_drv_failed_to_deduce_target_from_arch : Error<

clang/include/clang/Driver/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3034,6 +3034,10 @@ def fsycl_max_parallel_jobs_EQ : Joined<["-"], "fsycl-max-parallel-link-jobs=">,
30343034
"or AOT compilation of each device image.">;
30353035
def : Flag<["-"], "fsycl-rdc">, Flags<[CoreOption]>, Alias<fgpu_rdc>;
30363036
def : Flag<["-"], "fno-sycl-rdc">, Flags<[CoreOption]>, Alias<fno_gpu_rdc>;
3037+
def fsycl_optimize_non_user_code : Flag<["-"], "fsycl-optimize-non-user-code">,
3038+
Flags<[CC1Option, CoreOption]>, MarshallingInfoFlag<CodeGenOpts<"OptimizeSYCLFramework">>,
3039+
HelpText<"Option used in conjunction with -O0 to "
3040+
"optimize SYCL framework utility functions and leave user's kernel code unoptimized. (experimental)">;
30373041
def fsyntax_only : Flag<["-"], "fsyntax-only">,
30383042
Flags<[NoXarchOption,CoreOption,CC1Option,FC1Option,FlangOption]>, Group<Action_Group>,
30393043
HelpText<"Run the preprocessor, parser and semantic analysis stages">;

clang/include/clang/Sema/Sema.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,13 @@ class SYCLIntegrationHeader {
371371
NeedToEmitDeviceGlobalRegistration = true;
372372
}
373373

374+
/// Signals that emission of __sycl_host_pipe_registration type and
375+
/// declaration of variable __sycl_host_pipe_registrar of this type in
376+
/// integration header is required.
377+
void addHostPipeRegistration() {
378+
NeedToEmitHostPipeRegistration = true;
379+
}
380+
374381
private:
375382
// Kernel actual parameter descriptor.
376383
struct KernelParamDesc {
@@ -454,6 +461,10 @@ class SYCLIntegrationHeader {
454461
/// Keeps track of whether declaration of __sycl_device_global_registration
455462
/// type and __sycl_device_global_registrar variable are required to emit.
456463
bool NeedToEmitDeviceGlobalRegistration = false;
464+
465+
/// Keeps track of whether declaration of __sycl_host_pipe_registration
466+
/// type and __sycl_host_pipe_registrar variable are required to emit.
467+
bool NeedToEmitHostPipeRegistration = false;
457468
};
458469

459470
class SYCLIntegrationFooter {

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include "llvm/Passes/PassBuilder.h"
4747
#include "llvm/Passes/PassPlugin.h"
4848
#include "llvm/Passes/StandardInstrumentations.h"
49+
#include "llvm/SYCLLowerIR/CompileTimePropertiesPass.h"
4950
#include "llvm/SYCLLowerIR/ESIMD/ESIMDVerifier.h"
5051
#include "llvm/SYCLLowerIR/LowerWGLocalMemory.h"
5152
#include "llvm/SYCLLowerIR/MutatePrintfAddrspace.h"
@@ -850,6 +851,9 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
850851
// Only enable CGProfilePass when using integrated assembler, since
851852
// non-integrated assemblers don't recognize .cgprofile section.
852853
PTO.CallGraphProfile = !CodeGenOpts.DisableIntegratedAS;
854+
// Enable a custom optimization pipeline for non-user SYCL code.
855+
PTO.OptimizeSYCLFramework =
856+
CodeGenOpts.OptimizeSYCLFramework && !CodeGenOpts.DisableLLVMPasses;
853857

854858
LoopAnalysisManager LAM;
855859
FunctionAnalysisManager FAM;
@@ -1053,6 +1057,9 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
10531057
// Allocate static local memory in SYCL kernel scope for each allocation
10541058
// call.
10551059
MPM.addPass(SYCLLowerWGLocalMemoryPass());
1060+
1061+
// Process properties and annotations
1062+
MPM.addPass(CompileTimePropertiesPass());
10561063
}
10571064
}
10581065

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12397,8 +12397,8 @@ static Value *getMaskVecValue(CodeGenFunction &CGF, Value *Mask,
1239712397
static Value *EmitX86MaskedStore(CodeGenFunction &CGF, ArrayRef<Value *> Ops,
1239812398
Align Alignment) {
1239912399
// Cast the pointer to right type.
12400-
Value *Ptr = CGF.Builder.CreateBitCast(Ops[0],
12401-
llvm::PointerType::getUnqual(Ops[1]->getType()));
12400+
Value *Ptr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
12401+
Ops[0], llvm::PointerType::getUnqual(Ops[1]->getType()));
1240212402

1240312403
Value *MaskVec = getMaskVecValue(
1240412404
CGF, Ops[2],
@@ -12411,8 +12411,8 @@ static Value *EmitX86MaskedLoad(CodeGenFunction &CGF, ArrayRef<Value *> Ops,
1241112411
Align Alignment) {
1241212412
// Cast the pointer to right type.
1241312413
llvm::Type *Ty = Ops[1]->getType();
12414-
Value *Ptr =
12415-
CGF.Builder.CreateBitCast(Ops[0], llvm::PointerType::getUnqual(Ty));
12414+
Value *Ptr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
12415+
Ops[0], llvm::PointerType::getUnqual(Ty));
1241612416

1241712417
Value *MaskVec = getMaskVecValue(
1241812418
CGF, Ops[2], cast<llvm::FixedVectorType>(Ty)->getNumElements());

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2789,19 +2789,21 @@ Address CodeGenFunction::EmitFieldAnnotations(const FieldDecl *D,
27892789
llvm::PointerType *IntrinTy =
27902790
llvm::PointerType::getWithSamePointeeType(CGM.Int8PtrTy, AS);
27912791

2792-
llvm::Function *F = CGM.getIntrinsic(llvm::Intrinsic::ptr_annotation,
2793-
{IntrinTy, CGM.ConstGlobalsPtrTy});
2794-
27952792
// llvm.ptr.annotation intrinsic accepts a pointer to integer of any width -
27962793
// don't perform bitcasts if value is integer
27972794
if (Addr.getElementType()->isIntegerTy()) {
2795+
llvm::Function *F = CGM.getIntrinsic(llvm::Intrinsic::ptr_annotation,
2796+
{VTy, CGM.ConstGlobalsPtrTy});
27982797

27992798
for (const auto *I : D->specific_attrs<AnnotateAttr>())
28002799
V = EmitAnnotationCall(F, V, I->getAnnotation(), D->getLocation(), I);
28012800

28022801
return Address(V, Addr.getElementType(), Addr.getAlignment());
28032802
}
28042803

2804+
llvm::Function *F = CGM.getIntrinsic(llvm::Intrinsic::ptr_annotation,
2805+
{IntrinTy, CGM.ConstGlobalsPtrTy});
2806+
28052807
for (const auto *I : D->specific_attrs<AnnotateAttr>()) {
28062808
V = Builder.CreateBitCast(V, IntrinTy);
28072809
V = EmitAnnotationCall(F, V, I->getAnnotation(), D->getLocation(), I);

0 commit comments

Comments
 (0)