Skip to content

Commit 616df88

Browse files
committed
[AMDGPU] Enable amdgpu-sw-lower-lds pass in pipeline.
1 parent b68df87 commit 616df88

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,12 @@ static cl::opt<bool> EnableStructurizerWorkarounds(
343343
cl::desc("Enable workarounds for the StructurizeCFG pass"), cl::init(true),
344344
cl::Hidden);
345345

346+
static cl::opt<bool>
347+
EnableSwLowerLDS("amdgpu-enable-sw-lower-lds",
348+
cl::desc("Enable lowering of lds to global memory pass "
349+
"and asan instrument resulting IR."),
350+
cl::init(true), cl::Hidden);
351+
346352
static cl::opt<bool, true> EnableLowerModuleLDS(
347353
"amdgpu-enable-lower-module-lds", cl::desc("Enable lower module lds pass"),
348354
cl::location(AMDGPUTargetMachine::EnableLowerModuleLDS), cl::init(true),
@@ -765,6 +771,8 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
765771
// We want to support the -lto-partitions=N option as "best effort".
766772
// For that, we need to lower LDS earlier in the pipeline before the
767773
// module is partitioned for codegen.
774+
if (EnableSwLowerLDS)
775+
PM.addPass(AMDGPUSwLowerLDSPass(*this));
768776
if (EnableLowerModuleLDS)
769777
PM.addPass(AMDGPULowerModuleLDSPass(*this));
770778
if (EnableAMDGPUAttributor && Level != OptimizationLevel::O0)
@@ -1071,6 +1079,10 @@ void AMDGPUPassConfig::addIRPasses() {
10711079
// Replace OpenCL enqueued block function pointers with global variables.
10721080
addPass(createAMDGPUOpenCLEnqueuedBlockLoweringPass());
10731081

1082+
// Lower LDS accesses to global memory pass if address sanitizer is enabled.
1083+
if (EnableSwLowerLDS)
1084+
addPass(createAMDGPUSwLowerLDSLegacyPass(&TM));
1085+
10741086
// Runs before PromoteAlloca so the latter can account for function uses
10751087
if (EnableLowerModuleLDS) {
10761088
addPass(createAMDGPULowerModuleLDSLegacyPass(&TM));

0 commit comments

Comments
 (0)