|
11 | 11 | #include "clang/Basic/Diagnostic.h" |
12 | 12 | #include "clang/Basic/LangOptions.h" |
13 | 13 | #include "clang/Basic/TargetOptions.h" |
| 14 | +#include "clang/Basic/Targets/SPIR.h" |
14 | 15 | #include "clang/Frontend/FrontendDiagnostic.h" |
15 | 16 | #include "clang/Frontend/Utils.h" |
16 | 17 | #include "clang/Lex/HeaderSearchOptions.h" |
|
87 | 88 | #include "llvm/Transforms/Scalar.h" |
88 | 89 | #include "llvm/Transforms/Scalar/EarlyCSE.h" |
89 | 90 | #include "llvm/Transforms/Scalar/GVN.h" |
| 91 | +#include "llvm/Transforms/Scalar/InferAddressSpaces.h" |
90 | 92 | #include "llvm/Transforms/Scalar/JumpThreading.h" |
91 | 93 | #include "llvm/Transforms/Scalar/LowerMatrixIntrinsics.h" |
92 | 94 | #include "llvm/Transforms/Utils.h" |
@@ -897,6 +899,15 @@ void EmitAssemblyHelper::RunOptimizationPipeline( |
897 | 899 | MPM.addPass(SYCLPropagateAspectsUsagePass()); |
898 | 900 | }); |
899 | 901 |
|
| 902 | + // Add the InferAddressSpaces pass for all the SPIR[V] targets |
| 903 | + if (TargetTriple.isSPIR() || TargetTriple.isSPIRV()) { |
| 904 | + PB.registerOptimizerLastEPCallback( |
| 905 | + [](ModulePassManager &MPM, OptimizationLevel Level) { |
| 906 | + MPM.addPass(createModuleToFunctionPassAdaptor( |
| 907 | + InferAddressSpacesPass(clang::targets::SPIR_GENERIC_AS))); |
| 908 | + }); |
| 909 | + } |
| 910 | + |
900 | 911 | bool IsThinLTO = CodeGenOpts.PrepareForThinLTO; |
901 | 912 | bool IsLTO = CodeGenOpts.PrepareForLTO; |
902 | 913 |
|
@@ -999,7 +1010,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline( |
999 | 1010 | // -fsycl-instrument-device-code option was passed. This option can be used |
1000 | 1011 | // only with spir triple. |
1001 | 1012 | if (LangOpts.SYCLIsDevice && CodeGenOpts.SPIRITTAnnotations) { |
1002 | | - assert(llvm::Triple(TheModule->getTargetTriple()).isSPIR() && |
| 1013 | + assert(TargetTriple.isSPIR() && |
1003 | 1014 | "ITT annotations can only be added to a module with spir target"); |
1004 | 1015 | MPM.addPass(SPIRITTAnnotationsPass()); |
1005 | 1016 | } |
|
0 commit comments