Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
27597e2
Removed fsycl-early-opts and reimplemented fno-sycl-early-opts
Nov 28, 2022
8546bec
Fixed faulty flag assignment
Dec 2, 2022
78c9589
Reverted change to sycl-early-opts flag
Dec 6, 2022
d4ae056
Reverted two tests with unnecessary changes
Dec 6, 2022
dd3445e
Fixed the flag definition and tidied up the logic
Dec 7, 2022
2416d7d
clang-format'd BackendUtil changes
Dec 8, 2022
63c4430
Merge branch 'sycl' into alamzeds/fsycl-early-optimizations-flag
Dec 8, 2022
9c8bbb5
Resolved failing clang-format issues
Dec 8, 2022
bc085fd
Changed sycl-early-opts flag back to prev definition w/ change
Dec 9, 2022
95b0d3c
DisableLLVMPasses flag now handled by marshalling infrastructure
Dec 13, 2022
c69f54f
Optimization pipeline refactor to honour flags and fix logic
Dec 13, 2022
b13fa37
Update to group-local-memory test to honour disable-llvm-passes
Dec 13, 2022
af1324b
Rolled back uses_aspect test now it adheres to -disable-llvm-passes
Dec 13, 2022
5f45075
sub-group-size test change with updated flags
Dec 14, 2022
63270a6
Fixed functional pass invocation logic
Dec 14, 2022
7c36bb7
Converted inlining test to check nodes in AST
Dec 16, 2022
aac0dde
Reverted device_has test to respect disable_llvm_passes flag
Dec 19, 2022
b7586ff
Merge branch 'sycl' into alamzeds/fsycl-early-optimizations-flag
Dec 19, 2022
f8c9ab1
Ran clang-format over device_has sycl/test test
Dec 19, 2022
c46a0db
Refactored pipeline building logic after removing first SYCLPropagate…
Dec 20, 2022
639ae36
Merge branch 'sycl' into alamzeds/fsycl-early-optimizations-flag
Dec 20, 2022
5d39281
Tidied up and formatted pipeline if logic
Dec 20, 2022
2c90ec7
Let DisableSYCLEarlyOpts codegen opt be set by marshalling
Jan 3, 2023
786f8c0
Refactor to consolidate logic and clean up code paths
Jan 3, 2023
34c9d24
Merge branch 'sycl' into alamzeds/fsycl-early-optimizations-flag
Jan 3, 2023
c4c5274
Formatted changes
Jan 3, 2023
c2adfd0
Merge branch 'sycl' into alamzeds/fsycl-early-optimizations-flag
Jan 4, 2023
9871f46
Updated force inline kernel lambda test
Jan 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/CodeGenOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,9 @@ CODEGENOPT(OpaquePointers, 1, 0)
/// non-deleting destructors. (No effect on Microsoft ABI.)
CODEGENOPT(CtorDtorReturnThis, 1, 0)

/// Whether to disable the standard optimization pipeline for the SYCL device compiler.
CODEGENOPT(DisableSYCLEarlyOpts, 1, 0)

#undef CODEGENOPT
#undef ENUM_CODEGENOPT
#undef VALUE_CODEGENOPT
8 changes: 7 additions & 1 deletion clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -5107,7 +5107,13 @@ def : Flag<["-"], "fno-sycl-explicit-simd">,
Flags<[CoreOption, Deprecated]>,
Group<clang_ignored_legacy_options_Group>,
HelpText<"Disable SYCL explicit SIMD extension. (deprecated)">;
defm sycl_early_optimizations : OptOutCC1FFlag<"sycl-early-optimizations", "Enable", "Disable", " standard optimization pipeline for SYCL device compiler", [CoreOption]>;
def fsycl_early_optimizations : Flag<["-"], "fsycl-early-optimizations">,
Flags<[CoreOption]>, Group<f_Group>,
HelpText<"Enable standard optimization pipeline for SYCL device compiler">;
def fno_sycl_early_optimizations : Flag<["-"], "fno-sycl-early-optimizations">,
Comment thread
andylshort marked this conversation as resolved.
Outdated
Flags<[CC1Option, CoreOption]>, Group<f_Group>,
HelpText<"Disable standard optimization pipeline for SYCL device compiler">,
MarshallingInfoFlag<CodeGenOpts<"DisableSYCLEarlyOpts">>;
def fsycl_dead_args_optimization : Flag<["-"], "fsycl-dead-args-optimization">,
Group<sycl_Group>, Flags<[NoArgumentUnused, CoreOption]>, HelpText<"Enables "
"elimination of DPC++ dead kernel arguments">;
Expand Down
58 changes: 31 additions & 27 deletions clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -915,25 +915,25 @@ void EmitAssemblyHelper::RunOptimizationPipeline(

ModulePassManager MPM;

// FIXME: Change this when -fno-sycl-early-optimizations is not tied to
// -disable-llvm-passes.
if (CodeGenOpts.DisableLLVMPasses && LangOpts.SYCLIsDevice)
if (LangOpts.SYCLIsDevice && !CodeGenOpts.DisableSYCLEarlyOpts)
Comment thread
andylshort marked this conversation as resolved.
Outdated
MPM.addPass(SYCLPropagateAspectsUsagePass());

if (!CodeGenOpts.DisableLLVMPasses) {

// Map our optimization levels into one of the distinct levels used to
// configure the pipeline.
OptimizationLevel Level = mapToLevel(CodeGenOpts);

if (LangOpts.SYCLIsDevice)
if (LangOpts.SYCLIsDevice && !CodeGenOpts.DisableSYCLEarlyOpts)
Comment thread
andylshort marked this conversation as resolved.
Outdated
PB.registerPipelineStartEPCallback(
[&](ModulePassManager &MPM, OptimizationLevel Level) {
MPM.addPass(ESIMDVerifierPass(LangOpts.SYCLESIMDForceStatelessMem));
MPM.addPass(SYCLPropagateAspectsUsagePass());
});

// Add the InferAddressSpaces pass for all the SPIR[V] targets
if (TargetTriple.isSPIR() || TargetTriple.isSPIRV()) {
if ((TargetTriple.isSPIR() || TargetTriple.isSPIRV()) &&
!CodeGenOpts.DisableSYCLEarlyOpts) {
Comment thread
andylshort marked this conversation as resolved.
Outdated
PB.registerOptimizerLastEPCallback(
[](ModulePassManager &MPM, OptimizationLevel Level) {
MPM.addPass(createModuleToFunctionPassAdaptor(
Expand Down Expand Up @@ -1020,34 +1020,38 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
MPM.addPass(InstrProfiling(*Options, false));
});

if (CodeGenOpts.OptimizationLevel == 0) {
MPM = PB.buildO0DefaultPipeline(Level, IsLTO || IsThinLTO);
} else if (IsThinLTO) {
MPM = PB.buildThinLTOPreLinkDefaultPipeline(Level);
} else if (IsLTO) {
MPM = PB.buildLTOPreLinkDefaultPipeline(Level);
} else {
MPM = PB.buildPerModuleDefaultPipeline(Level);
if (!CodeGenOpts.DisableSYCLEarlyOpts) {
Comment thread
andylshort marked this conversation as resolved.
Outdated
if (CodeGenOpts.OptimizationLevel == 0) {
MPM = PB.buildO0DefaultPipeline(Level, IsLTO || IsThinLTO);
} else if (IsThinLTO) {
MPM = PB.buildThinLTOPreLinkDefaultPipeline(Level);
} else if (IsLTO) {
MPM = PB.buildLTOPreLinkDefaultPipeline(Level);
} else {
MPM = PB.buildPerModuleDefaultPipeline(Level);
}
}

if (!CodeGenOpts.MemoryProfileOutput.empty()) {
MPM.addPass(createModuleToFunctionPassAdaptor(MemProfilerPass()));
MPM.addPass(ModuleMemProfilerPass());
}
}
if (LangOpts.SYCLIsDevice) {
MPM.addPass(SYCLMutatePrintfAddrspacePass());
if (!CodeGenOpts.DisableLLVMPasses && LangOpts.EnableDAEInSpirKernels)
MPM.addPass(DeadArgumentEliminationSYCLPass());
}

// Add SPIRITTAnnotations pass to the pass manager if
// -fsycl-instrument-device-code option was passed. This option can be used
// only with spir triple.
if (LangOpts.SYCLIsDevice && CodeGenOpts.SPIRITTAnnotations) {
assert(TargetTriple.isSPIR() &&
"ITT annotations can only be added to a module with spir target");
MPM.addPass(SPIRITTAnnotationsPass());
if (LangOpts.SYCLIsDevice) {
MPM.addPass(SYCLMutatePrintfAddrspacePass());
if (LangOpts.EnableDAEInSpirKernels)
MPM.addPass(DeadArgumentEliminationSYCLPass());
}

// Add SPIRITTAnnotations pass to the pass manager if
// -fsycl-instrument-device-code option was passed. This option can be used
// only with spir triple.
if (LangOpts.SYCLIsDevice && CodeGenOpts.SPIRITTAnnotations &&
!CodeGenOpts.DisableSYCLEarlyOpts) {
Comment thread
andylshort marked this conversation as resolved.
Outdated
assert(TargetTriple.isSPIR() &&
"ITT annotations can only be added to a module with spir target");
MPM.addPass(SPIRITTAnnotationsPass());
}
}

// Allocate static local memory in SYCL kernel scope for each allocation
Comment thread
andylshort marked this conversation as resolved.
Outdated
Expand All @@ -1056,7 +1060,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
// Group local memory pass depends on inlining. Turn it on even in case if
// all llvm passes or SYCL early optimizations are disabled.
// FIXME: Remove this workaround when dependency on inlining is eliminated.
if (CodeGenOpts.DisableLLVMPasses)
if (CodeGenOpts.DisableLLVMPasses || CodeGenOpts.DisableSYCLEarlyOpts)
MPM.addPass(AlwaysInlinerPass(false));
MPM.addPass(SYCLLowerWGLocalMemoryPass());
}
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1689,10 +1689,10 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
{std::string(Split.first), std::string(Split.second)});
}

Opts.DisableLLVMPasses =
Args.hasArg(OPT_disable_llvm_passes) ||
(Args.hasArg(OPT_fsycl_is_device) && T.isSPIR() &&
Args.hasArg(OPT_fno_sycl_early_optimizations));
Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
Comment thread
andylshort marked this conversation as resolved.
Outdated

Opts.DisableSYCLEarlyOpts = Args.hasArg(OPT_fsycl_is_device) && T.isSPIR() &&
Comment thread
andylshort marked this conversation as resolved.
Outdated
Args.hasArg(OPT_fno_sycl_early_optimizations);

const llvm::Triple::ArchType DebugEntryValueArchs[] = {
llvm::Triple::x86, llvm::Triple::x86_64, llvm::Triple::aarch64,
Expand Down