|
21 | 21 | #include "llvm/Analysis/TargetTransformInfo.h" |
22 | 22 | #include "llvm/Bitcode/BitcodeWriterPass.h" |
23 | 23 | #include "llvm/Demangle/Demangle.h" |
24 | | -#include "llvm/GenXIntrinsics/GenXSPIRVWriterAdaptor.h" |
25 | 24 | #include "llvm/IR/Dominators.h" |
26 | 25 | #include "llvm/IR/LLVMContext.h" |
27 | 26 | #include "llvm/IR/Module.h" |
|
32 | 31 | #include "llvm/SYCLLowerIR/CompileTimePropertiesPass.h" |
33 | 32 | #include "llvm/SYCLLowerIR/DeviceConfigFile.hpp" |
34 | 33 | #include "llvm/SYCLLowerIR/ESIMD/ESIMDUtils.h" |
35 | | -#include "llvm/SYCLLowerIR/ESIMD/LowerESIMD.h" |
36 | 34 | #include "llvm/SYCLLowerIR/HostPipes.h" |
37 | 35 | #include "llvm/SYCLLowerIR/LowerInvokeSimd.h" |
38 | 36 | #include "llvm/SYCLLowerIR/SYCLJointMatrixTransform.h" |
39 | 37 | #include "llvm/SYCLLowerIR/SYCLUtils.h" |
40 | 38 | #include "llvm/SYCLLowerIR/SpecConstants.h" |
41 | 39 | #include "llvm/SYCLLowerIR/Support.h" |
42 | 40 | #include "llvm/SYCLPostLink/ComputeModuleRuntimeInfo.h" |
| 41 | +#include "llvm/SYCLPostLink/ESIMDPostSplitProcessing.h" |
43 | 42 | #include "llvm/SYCLPostLink/ModuleSplitter.h" |
44 | 43 | #include "llvm/Support/CommandLine.h" |
45 | 44 | #include "llvm/Support/FileSystem.h" |
|
49 | 48 | #include "llvm/Support/SourceMgr.h" |
50 | 49 | #include "llvm/Support/SystemUtils.h" |
51 | 50 | #include "llvm/Support/WithColor.h" |
52 | | -#include "llvm/Transforms/IPO/AlwaysInliner.h" |
53 | 51 | #include "llvm/Transforms/IPO/StripDeadPrototypes.h" |
54 | | -#include "llvm/Transforms/InstCombine/InstCombine.h" |
55 | | -#include "llvm/Transforms/Scalar.h" |
56 | | -#include "llvm/Transforms/Scalar/DCE.h" |
57 | | -#include "llvm/Transforms/Scalar/EarlyCSE.h" |
58 | | -#include "llvm/Transforms/Scalar/SROA.h" |
59 | 52 |
|
60 | 53 | #include <algorithm> |
61 | 54 | #include <memory> |
@@ -361,69 +354,6 @@ std::string saveModuleSymbolTable(const module_split::ModuleDesc &MD, int I, |
361 | 354 | return OutFileName; |
362 | 355 | } |
363 | 356 |
|
364 | | -template <class PassClass> bool runModulePass(Module &M) { |
365 | | - ModulePassManager MPM; |
366 | | - ModuleAnalysisManager MAM; |
367 | | - // Register required analysis |
368 | | - MAM.registerPass([&] { return PassInstrumentationAnalysis(); }); |
369 | | - MPM.addPass(PassClass{}); |
370 | | - PreservedAnalyses Res = MPM.run(M, MAM); |
371 | | - return !Res.areAllPreserved(); |
372 | | -} |
373 | | - |
374 | | -// When ESIMD code was separated from the regular SYCL code, |
375 | | -// we can safely process ESIMD part. |
376 | | -// TODO: support options like -debug-pass, -print-[before|after], and others |
377 | | -bool lowerEsimdConstructs(module_split::ModuleDesc &MD) { |
378 | | - LoopAnalysisManager LAM; |
379 | | - CGSCCAnalysisManager CGAM; |
380 | | - FunctionAnalysisManager FAM; |
381 | | - ModuleAnalysisManager MAM; |
382 | | - |
383 | | - PassBuilder PB; |
384 | | - PB.registerModuleAnalyses(MAM); |
385 | | - PB.registerCGSCCAnalyses(CGAM); |
386 | | - PB.registerFunctionAnalyses(FAM); |
387 | | - PB.registerLoopAnalyses(LAM); |
388 | | - PB.crossRegisterProxies(LAM, FAM, CGAM, MAM); |
389 | | - |
390 | | - ModulePassManager MPM; |
391 | | - MPM.addPass(SYCLLowerESIMDPass(!SplitEsimd)); |
392 | | - |
393 | | - if (!OptLevelO0) { |
394 | | - FunctionPassManager FPM; |
395 | | - FPM.addPass(SROAPass(SROAOptions::ModifyCFG)); |
396 | | - MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM))); |
397 | | - } |
398 | | - MPM.addPass(ESIMDOptimizeVecArgCallConvPass{}); |
399 | | - FunctionPassManager MainFPM; |
400 | | - MainFPM.addPass(ESIMDLowerLoadStorePass{}); |
401 | | - |
402 | | - if (!OptLevelO0) { |
403 | | - MainFPM.addPass(SROAPass(SROAOptions::ModifyCFG)); |
404 | | - MainFPM.addPass(EarlyCSEPass(true)); |
405 | | - MainFPM.addPass(InstCombinePass{}); |
406 | | - MainFPM.addPass(DCEPass{}); |
407 | | - // TODO: maybe remove some passes below that don't affect code quality |
408 | | - MainFPM.addPass(SROAPass(SROAOptions::ModifyCFG)); |
409 | | - MainFPM.addPass(EarlyCSEPass(true)); |
410 | | - MainFPM.addPass(InstCombinePass{}); |
411 | | - MainFPM.addPass(DCEPass{}); |
412 | | - } |
413 | | - MPM.addPass(ESIMDLowerSLMReservationCalls{}); |
414 | | - MPM.addPass(createModuleToFunctionPassAdaptor(std::move(MainFPM))); |
415 | | - MPM.addPass(GenXSPIRVWriterAdaptor(/*RewriteTypes=*/true, |
416 | | - /*RewriteSingleElementVectorsIn*/ false)); |
417 | | - // GenXSPIRVWriterAdaptor pass replaced some functions with "rewritten" |
418 | | - // versions so the entry point table must be rebuilt. |
419 | | - // TODO Change entry point search to analysis? |
420 | | - std::vector<std::string> Names; |
421 | | - MD.saveEntryPointNames(Names); |
422 | | - PreservedAnalyses Res = MPM.run(MD.getModule(), MAM); |
423 | | - MD.rebuildEntryPoints(Names); |
424 | | - return !Res.areAllPreserved(); |
425 | | -} |
426 | | - |
427 | 357 | // Compute the filename suffix for the module |
428 | 358 | StringRef getModuleSuffix(const module_split::ModuleDesc &MD) { |
429 | 359 | return MD.isESIMD() ? "_esimd" : ""; |
@@ -610,7 +540,7 @@ handleESIMD(module_split::ModuleDesc &&MDesc, bool &Modified, |
610 | 540 | for (auto &MD : Result) { |
611 | 541 | DUMP_ENTRY_POINTS(MD.entries(), MD.Name.c_str(), 3); |
612 | 542 | if (LowerEsimd && MD.isESIMD()) |
613 | | - Modified |= lowerEsimdConstructs(MD); |
| 543 | + Modified |= sycl::lowerESIMDConstructs(MD, OptLevelO0, SplitEsimd); |
614 | 544 | } |
615 | 545 |
|
616 | 546 | if (!SplitEsimd && Result.size() > 1) { |
|
0 commit comments