@@ -337,6 +337,10 @@ static cl::opt<bool> EnableStructurizerWorkarounds(
337
337
cl::desc (" Enable workarounds for the StructurizeCFG pass" ), cl::init(true ),
338
338
cl::Hidden);
339
339
340
+ static cl::opt<bool > EnableSwLowerLDS (" amdgpu-enable-sw-lower-lds" ,
341
+ cl::desc (" Enable sw lower lds pass" ),
342
+ cl::init(true ), cl::Hidden);
343
+
340
344
static cl::opt<bool , true > EnableLowerModuleLDS (
341
345
" amdgpu-enable-lower-module-lds" , cl::desc(" Enable lower module lds pass" ),
342
346
cl::location(AMDGPUTargetMachine::EnableLowerModuleLDS), cl::init(true ),
@@ -736,6 +740,8 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
736
740
// We want to support the -lto-partitions=N option as "best effort".
737
741
// For that, we need to lower LDS earlier in the pipeline before the
738
742
// module is partitioned for codegen.
743
+ if (EnableSwLowerLDS)
744
+ PM.addPass (AMDGPUSwLowerLDSPass (*this ));
739
745
if (EnableLowerModuleLDS)
740
746
PM.addPass (AMDGPULowerModuleLDSPass (*this ));
741
747
});
@@ -1032,6 +1038,10 @@ void AMDGPUPassConfig::addIRPasses() {
1032
1038
// Replace OpenCL enqueued block function pointers with global variables.
1033
1039
addPass (createAMDGPUOpenCLEnqueuedBlockLoweringPass ());
1034
1040
1041
+ // Lower LDS accesses to global memory if address sanitizer is enabled.
1042
+ if (EnableSwLowerLDS)
1043
+ addPass (createAMDGPUSwLowerLDSLegacyPass (&TM));
1044
+
1035
1045
// Runs before PromoteAlloca so the latter can account for function uses
1036
1046
if (EnableLowerModuleLDS) {
1037
1047
addPass (createAMDGPULowerModuleLDSLegacyPass (&TM));
0 commit comments