Skip to content
Closed
Changes from 2 commits
Commits
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
15 changes: 9 additions & 6 deletions clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
// configure the pipeline.
OptimizationLevel Level = mapToLevel(CodeGenOpts);

if (LangOpts.SYCLIsDevice)
if (LangOpts.SYCLIsDevice) {
PB.registerPipelineStartEPCallback([&](ModulePassManager &MPM,
OptimizationLevel Level) {
MPM.addPass(SYCLVirtualFunctionsAnalysisPass());
Expand All @@ -1043,7 +1043,14 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
/*ExcludeAspects=*/{"fp64"}));
MPM.addPass(SYCLPropagateJointMatrixUsagePass());
});
else if (LangOpts.SYCLIsHost && !LangOpts.SYCLESIMDBuildHostCode)
PB.registerOptimizerEarlyEPCallback([](ModulePassManager &MPM,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason to use registerOptimizerEarlyEPCallback instead of registerPipelineStartEPCallback?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in https://github.com/intel/llvm/pull/16183/files/43526397fa2b4c559666fdfd6f302bfba7409255#r1857546652, we need to make sure this pass run after AlwaysIniner, moving to PipelineStart is what was tried in #16183, it is before alwaysinliner and too early.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsji, could you please extend the comment at lines 1049-1050 with the requirement to run AlwaysInliner pass before SYCLLowerWGLocalMemoryPass?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure.

OptimizationLevel Level,
ThinOrFullLTOPhase) {
// Lowers __sycl_allocateLocalMemory and __sycl_dynamicLocalMemoryPlaceholder
// builtin calls.
MPM.addPass(SYCLLowerWGLocalMemoryPass());
});
} else if (LangOpts.SYCLIsHost && !LangOpts.SYCLESIMDBuildHostCode)
PB.registerPipelineStartEPCallback(
[&](ModulePassManager &MPM, OptimizationLevel Level) {
MPM.addPass(ESIMDRemoveHostCodePass());
Expand Down Expand Up @@ -1191,10 +1198,6 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
MPM.addPass(SPIRITTAnnotationsPass());
}

// Allocate static local memory in SYCL kernel scope for each allocation
// call.
MPM.addPass(SYCLLowerWGLocalMemoryPass());

// Process properties and annotations
MPM.addPass(CompileTimePropertiesPass());

Expand Down
Loading