diff --git a/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp b/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp @@ -1305,6 +1305,18 @@ GlobalAddressSDNode *G = cast(Op); const GlobalValue *GV = G->getGlobal(); + if (G->getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS) { + if (!MFI->isModuleEntryFunction()) { + if (const GlobalVariable *GVar = dyn_cast(GV)) { + if (AMDGPUMachineFunction::isKnownAddressLDSGlobal(*GVar)) { + unsigned Offset = + AMDGPUMachineFunction::calculateKnownAddressOfLDSGlobal(*GVar); + return DAG.getConstant(Offset, SDLoc(Op), Op.getValueType()); + } + } + } + } + if (G->getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS || G->getAddressSpace() == AMDGPUAS::REGION_ADDRESS) { if (!MFI->isModuleEntryFunction() && diff --git a/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp b/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp @@ -162,7 +162,7 @@ cl::opt LoweringKindLoc( "amdgpu-lower-module-lds-strategy", cl::desc("Specify lowering strategy for function LDS access:"), cl::Hidden, - cl::init(LoweringKind::module), + cl::init(LoweringKind::hybrid), cl::values( clEnumValN(LoweringKind::table, "table", "Lower via table lookup"), clEnumValN(LoweringKind::module, "module", "Lower via module struct"),