1 //===-- AMDGPULowerModuleLDSPass.cpp ------------------------------*- C++ -*-=// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This pass eliminates LDS uses from non-kernel functions. 10 // 11 // The strategy is to create a new struct with a field for each LDS variable 12 // and allocate that struct at the same address for every kernel. Uses of the 13 // original LDS variables are then replaced with compile time offsets from that 14 // known address. AMDGPUMachineFunction allocates the LDS global. 15 // 16 // Local variables with constant annotation or non-undef initializer are passed 17 // through unchanged for simplification or error diagnostics in later passes. 18 // 19 // To reduce the memory overhead variables that are only used by kernels are 20 // excluded from this transform. The analysis to determine whether a variable 21 // is only used by a kernel is cheap and conservative so this may allocate 22 // a variable in every kernel when it was not strictly necessary to do so. 23 // 24 // A possible future refinement is to specialise the structure per-kernel, so 25 // that fields can be elided based on more expensive analysis. 26 // 27 //===----------------------------------------------------------------------===// 28 29 #include "AMDGPU.h" 30 #include "Utils/AMDGPUBaseInfo.h" 31 #include "Utils/AMDGPUMemoryUtils.h" 32 #include "llvm/ADT/BitVector.h" 33 #include "llvm/ADT/DenseMap.h" 34 #include "llvm/ADT/STLExtras.h" 35 #include "llvm/ADT/SetVector.h" 36 #include "llvm/Analysis/CallGraph.h" 37 #include "llvm/IR/Constants.h" 38 #include "llvm/IR/DerivedTypes.h" 39 #include "llvm/IR/IRBuilder.h" 40 #include "llvm/IR/InlineAsm.h" 41 #include "llvm/IR/Instructions.h" 42 #include "llvm/IR/MDBuilder.h" 43 #include "llvm/InitializePasses.h" 44 #include "llvm/Pass.h" 45 #include "llvm/Support/CommandLine.h" 46 #include "llvm/Support/Debug.h" 47 #include "llvm/Support/OptimizedStructLayout.h" 48 #include "llvm/Transforms/Utils/ModuleUtils.h" 49 #include <tuple> 50 #include <vector> 51 52 #define DEBUG_TYPE "amdgpu-lower-module-lds" 53 54 using namespace llvm; 55 56 static cl::opt<bool> SuperAlignLDSGlobals( 57 "amdgpu-super-align-lds-globals", 58 cl::desc("Increase alignment of LDS if it is not on align boundary"), 59 cl::init(true), cl::Hidden); 60 61 namespace { 62 class AMDGPULowerModuleLDS : public ModulePass { 63 64 static void removeFromUsedList(Module &M, StringRef Name, 65 SmallPtrSetImpl<Constant *> &ToRemove) { 66 GlobalVariable *GV = M.getNamedGlobal(Name); 67 if (!GV || ToRemove.empty()) { 68 return; 69 } 70 71 SmallVector<Constant *, 16> Init; 72 auto *CA = cast<ConstantArray>(GV->getInitializer()); 73 for (auto &Op : CA->operands()) { 74 // ModuleUtils::appendToUsed only inserts Constants 75 Constant *C = cast<Constant>(Op); 76 if (!ToRemove.contains(C->stripPointerCasts())) { 77 Init.push_back(C); 78 } 79 } 80 81 if (Init.size() == CA->getNumOperands()) { 82 return; // none to remove 83 } 84 85 GV->eraseFromParent(); 86 87 for (Constant *C : ToRemove) { 88 C->removeDeadConstantUsers(); 89 } 90 91 if (!Init.empty()) { 92 ArrayType *ATy = 93 ArrayType::get(Type::getInt8PtrTy(M.getContext()), Init.size()); 94 GV = 95 new llvm::GlobalVariable(M, ATy, false, GlobalValue::AppendingLinkage, 96 ConstantArray::get(ATy, Init), Name); 97 GV->setSection("llvm.metadata"); 98 } 99 } 100 101 static void 102 removeFromUsedLists(Module &M, 103 const std::vector<GlobalVariable *> &LocalVars) { 104 // The verifier rejects used lists containing an inttoptr of a constant 105 // so remove the variables from these lists before replaceAllUsesWith 106 107 SmallPtrSet<Constant *, 32> LocalVarsSet; 108 for (GlobalVariable *LocalVar : LocalVars) 109 if (Constant *C = dyn_cast<Constant>(LocalVar->stripPointerCasts())) 110 LocalVarsSet.insert(C); 111 removeFromUsedList(M, "llvm.used", LocalVarsSet); 112 removeFromUsedList(M, "llvm.compiler.used", LocalVarsSet); 113 } 114 115 static void markUsedByKernel(IRBuilder<> &Builder, Function *Func, 116 GlobalVariable *SGV) { 117 // The llvm.amdgcn.module.lds instance is implicitly used by all kernels 118 // that might call a function which accesses a field within it. This is 119 // presently approximated to 'all kernels' if there are any such functions 120 // in the module. This implicit use is redefined as an explicit use here so 121 // that later passes, specifically PromoteAlloca, account for the required 122 // memory without any knowledge of this transform. 123 124 // An operand bundle on llvm.donothing works because the call instruction 125 // survives until after the last pass that needs to account for LDS. It is 126 // better than inline asm as the latter survives until the end of codegen. A 127 // totally robust solution would be a function with the same semantics as 128 // llvm.donothing that takes a pointer to the instance and is lowered to a 129 // no-op after LDS is allocated, but that is not presently necessary. 130 131 LLVMContext &Ctx = Func->getContext(); 132 133 Builder.SetInsertPoint(Func->getEntryBlock().getFirstNonPHI()); 134 135 FunctionType *FTy = FunctionType::get(Type::getVoidTy(Ctx), {}); 136 137 Function *Decl = 138 Intrinsic::getDeclaration(Func->getParent(), Intrinsic::donothing, {}); 139 140 Value *UseInstance[1] = {Builder.CreateInBoundsGEP( 141 SGV->getValueType(), SGV, ConstantInt::get(Type::getInt32Ty(Ctx), 0))}; 142 143 Builder.CreateCall(FTy, Decl, {}, 144 {OperandBundleDefT<Value *>("ExplicitUse", UseInstance)}, 145 ""); 146 } 147 148 static bool eliminateConstantExprUsesOfLDSFromAllInstructions(Module &M) { 149 // Constants are uniqued within LLVM. A ConstantExpr referring to a LDS 150 // global may have uses from multiple different functions as a result. 151 // This pass specialises LDS variables with respect to the kernel that 152 // allocates them. 153 154 // This is semantically equivalent to: 155 // for (auto &F : M.functions()) 156 // for (auto &BB : F) 157 // for (auto &I : BB) 158 // for (Use &Op : I.operands()) 159 // if (constantExprUsesLDS(Op)) 160 // replaceConstantExprInFunction(I, Op); 161 162 bool Changed = false; 163 164 // Find all ConstantExpr that are direct users of an LDS global 165 SmallVector<ConstantExpr *> Stack; 166 for (auto &GV : M.globals()) 167 if (AMDGPU::isLDSVariableToLower(GV)) 168 for (User *U : GV.users()) 169 if (ConstantExpr *C = dyn_cast<ConstantExpr>(U)) 170 Stack.push_back(C); 171 172 // Expand to include constexpr users of direct users 173 SetVector<ConstantExpr *> ConstExprUsersOfLDS; 174 while (!Stack.empty()) { 175 ConstantExpr *V = Stack.pop_back_val(); 176 if (ConstExprUsersOfLDS.contains(V)) 177 continue; 178 179 ConstExprUsersOfLDS.insert(V); 180 181 for (auto *Nested : V->users()) 182 if (ConstantExpr *CE = dyn_cast<ConstantExpr>(Nested)) 183 Stack.push_back(CE); 184 } 185 186 // Find all instructions that use any of the ConstExpr users of LDS 187 SetVector<Instruction *> InstructionWorklist; 188 for (ConstantExpr *CE : ConstExprUsersOfLDS) 189 for (User *U : CE->users()) 190 if (auto *I = dyn_cast<Instruction>(U)) 191 InstructionWorklist.insert(I); 192 193 // Replace those ConstExpr operands with instructions 194 while (!InstructionWorklist.empty()) { 195 Instruction *I = InstructionWorklist.pop_back_val(); 196 for (Use &U : I->operands()) { 197 198 auto *BI = I; 199 if (auto *Phi = dyn_cast<PHINode>(I)) { 200 BasicBlock *BB = Phi->getIncomingBlock(U); 201 BasicBlock::iterator It = BB->getFirstInsertionPt(); 202 assert(It != BB->end() && "Unexpected empty basic block"); 203 BI = &(*(It)); 204 } 205 206 if (ConstantExpr *C = dyn_cast<ConstantExpr>(U.get())) { 207 if (ConstExprUsersOfLDS.contains(C)) { 208 Changed = true; 209 Instruction *NI = C->getAsInstruction(BI); 210 InstructionWorklist.insert(NI); 211 U.set(NI); 212 C->removeDeadConstantUsers(); 213 } 214 } 215 } 216 } 217 218 return Changed; 219 } 220 221 public: 222 static char ID; 223 224 AMDGPULowerModuleLDS() : ModulePass(ID) { 225 initializeAMDGPULowerModuleLDSPass(*PassRegistry::getPassRegistry()); 226 } 227 228 bool runOnModule(Module &M) override { 229 LLVMContext &Ctx = M.getContext(); 230 CallGraph CG = CallGraph(M); 231 bool Changed = superAlignLDSGlobals(M); 232 233 Changed |= eliminateConstantExprUsesOfLDSFromAllInstructions(M); 234 235 // Move variables used by functions into amdgcn.module.lds 236 std::vector<GlobalVariable *> ModuleScopeVariables = 237 AMDGPU::findLDSVariablesToLower(M, nullptr); 238 if (!ModuleScopeVariables.empty()) { 239 std::string VarName = "llvm.amdgcn.module.lds"; 240 241 GlobalVariable *SGV; 242 DenseMap<GlobalVariable *, Constant *> LDSVarsToConstantGEP; 243 std::tie(SGV, LDSVarsToConstantGEP) = 244 createLDSVariableReplacement(M, VarName, ModuleScopeVariables); 245 246 appendToCompilerUsed( 247 M, {static_cast<GlobalValue *>( 248 ConstantExpr::getPointerBitCastOrAddrSpaceCast( 249 cast<Constant>(SGV), Type::getInt8PtrTy(Ctx)))}); 250 251 removeFromUsedLists(M, ModuleScopeVariables); 252 replaceLDSVariablesWithStruct(M, ModuleScopeVariables, SGV, 253 LDSVarsToConstantGEP, 254 [](Use &) { return true; }); 255 256 // This ensures the variable is allocated when called functions access it. 257 // It also lets other passes, specifically PromoteAlloca, accurately 258 // calculate how much LDS will be used by the kernel after lowering. 259 260 IRBuilder<> Builder(Ctx); 261 for (Function &Func : M.functions()) { 262 if (!Func.isDeclaration() && AMDGPU::isKernelCC(&Func)) { 263 const CallGraphNode *N = CG[&Func]; 264 const bool CalleesRequireModuleLDS = N->size() > 0; 265 266 if (CalleesRequireModuleLDS) { 267 // If a function this kernel might call requires module LDS, 268 // annotate the kernel to let later passes know it will allocate 269 // this structure, even if not apparent from the IR. 270 markUsedByKernel(Builder, &Func, SGV); 271 } else { 272 // However if we are certain this kernel cannot call a function that 273 // requires module LDS, annotate the kernel so the backend can elide 274 // the allocation without repeating callgraph walks. 275 Func.addFnAttr("amdgpu-elide-module-lds"); 276 } 277 } 278 } 279 280 Changed = true; 281 } 282 283 // Move variables used by kernels into per-kernel instances 284 for (Function &F : M.functions()) { 285 if (F.isDeclaration()) 286 continue; 287 288 // Only lower compute kernels' LDS. 289 if (!AMDGPU::isKernel(F.getCallingConv())) 290 continue; 291 292 std::vector<GlobalVariable *> KernelUsedVariables = 293 AMDGPU::findLDSVariablesToLower(M, &F); 294 295 if (!KernelUsedVariables.empty()) { 296 std::string VarName = 297 (Twine("llvm.amdgcn.kernel.") + F.getName() + ".lds").str(); 298 GlobalVariable *SGV; 299 DenseMap<GlobalVariable *, Constant *> LDSVarsToConstantGEP; 300 std::tie(SGV, LDSVarsToConstantGEP) = 301 createLDSVariableReplacement(M, VarName, KernelUsedVariables); 302 303 removeFromUsedLists(M, KernelUsedVariables); 304 replaceLDSVariablesWithStruct( 305 M, KernelUsedVariables, SGV, LDSVarsToConstantGEP, [&F](Use &U) { 306 Instruction *I = dyn_cast<Instruction>(U.getUser()); 307 return I && I->getFunction() == &F; 308 }); 309 Changed = true; 310 } 311 } 312 313 for (auto &GV : make_early_inc_range(M.globals())) 314 if (AMDGPU::isLDSVariableToLower(GV)) { 315 GV.removeDeadConstantUsers(); 316 if (GV.use_empty()) 317 GV.eraseFromParent(); 318 } 319 320 return Changed; 321 } 322 323 private: 324 // Increase the alignment of LDS globals if necessary to maximise the chance 325 // that we can use aligned LDS instructions to access them. 326 static bool superAlignLDSGlobals(Module &M) { 327 const DataLayout &DL = M.getDataLayout(); 328 bool Changed = false; 329 if (!SuperAlignLDSGlobals) { 330 return Changed; 331 } 332 333 for (auto &GV : M.globals()) { 334 if (GV.getType()->getPointerAddressSpace() != AMDGPUAS::LOCAL_ADDRESS) { 335 // Only changing alignment of LDS variables 336 continue; 337 } 338 if (!GV.hasInitializer()) { 339 // cuda/hip extern __shared__ variable, leave alignment alone 340 continue; 341 } 342 343 Align Alignment = AMDGPU::getAlign(DL, &GV); 344 TypeSize GVSize = DL.getTypeAllocSize(GV.getValueType()); 345 346 if (GVSize > 8) { 347 // We might want to use a b96 or b128 load/store 348 Alignment = std::max(Alignment, Align(16)); 349 } else if (GVSize > 4) { 350 // We might want to use a b64 load/store 351 Alignment = std::max(Alignment, Align(8)); 352 } else if (GVSize > 2) { 353 // We might want to use a b32 load/store 354 Alignment = std::max(Alignment, Align(4)); 355 } else if (GVSize > 1) { 356 // We might want to use a b16 load/store 357 Alignment = std::max(Alignment, Align(2)); 358 } 359 360 if (Alignment != AMDGPU::getAlign(DL, &GV)) { 361 Changed = true; 362 GV.setAlignment(Alignment); 363 } 364 } 365 return Changed; 366 } 367 368 std::tuple<GlobalVariable *, DenseMap<GlobalVariable *, Constant *>> 369 createLDSVariableReplacement( 370 Module &M, std::string VarName, 371 std::vector<GlobalVariable *> const &LDSVarsToTransform) { 372 // Create a struct instance containing LDSVarsToTransform and map from those 373 // variables to ConstantExprGEP 374 // Variables may be introduced to meet alignment requirements. No aliasing 375 // metadata is useful for these as they have no uses. Erased before return. 376 377 LLVMContext &Ctx = M.getContext(); 378 const DataLayout &DL = M.getDataLayout(); 379 assert(!LDSVarsToTransform.empty()); 380 381 SmallVector<OptimizedStructLayoutField, 8> LayoutFields; 382 LayoutFields.reserve(LDSVarsToTransform.size()); 383 for (GlobalVariable *GV : LDSVarsToTransform) { 384 OptimizedStructLayoutField F(GV, DL.getTypeAllocSize(GV->getValueType()), 385 AMDGPU::getAlign(DL, GV)); 386 LayoutFields.emplace_back(F); 387 } 388 389 performOptimizedStructLayout(LayoutFields); 390 391 std::vector<GlobalVariable *> LocalVars; 392 BitVector IsPaddingField; 393 LocalVars.reserve(LDSVarsToTransform.size()); // will be at least this large 394 IsPaddingField.reserve(LDSVarsToTransform.size()); 395 { 396 uint64_t CurrentOffset = 0; 397 for (size_t I = 0; I < LayoutFields.size(); I++) { 398 GlobalVariable *FGV = static_cast<GlobalVariable *>( 399 const_cast<void *>(LayoutFields[I].Id)); 400 Align DataAlign = LayoutFields[I].Alignment; 401 402 uint64_t DataAlignV = DataAlign.value(); 403 if (uint64_t Rem = CurrentOffset % DataAlignV) { 404 uint64_t Padding = DataAlignV - Rem; 405 406 // Append an array of padding bytes to meet alignment requested 407 // Note (o + (a - (o % a)) ) % a == 0 408 // (offset + Padding ) % align == 0 409 410 Type *ATy = ArrayType::get(Type::getInt8Ty(Ctx), Padding); 411 LocalVars.push_back(new GlobalVariable( 412 M, ATy, false, GlobalValue::InternalLinkage, UndefValue::get(ATy), 413 "", nullptr, GlobalValue::NotThreadLocal, AMDGPUAS::LOCAL_ADDRESS, 414 false)); 415 IsPaddingField.push_back(true); 416 CurrentOffset += Padding; 417 } 418 419 LocalVars.push_back(FGV); 420 IsPaddingField.push_back(false); 421 CurrentOffset += LayoutFields[I].Size; 422 } 423 } 424 425 std::vector<Type *> LocalVarTypes; 426 LocalVarTypes.reserve(LocalVars.size()); 427 std::transform( 428 LocalVars.cbegin(), LocalVars.cend(), std::back_inserter(LocalVarTypes), 429 [](const GlobalVariable *V) -> Type * { return V->getValueType(); }); 430 431 StructType *LDSTy = StructType::create(Ctx, LocalVarTypes, VarName + ".t"); 432 433 Align StructAlign = AMDGPU::getAlign(DL, LocalVars[0]); 434 435 GlobalVariable *SGV = new GlobalVariable( 436 M, LDSTy, false, GlobalValue::InternalLinkage, UndefValue::get(LDSTy), 437 VarName, nullptr, GlobalValue::NotThreadLocal, AMDGPUAS::LOCAL_ADDRESS, 438 false); 439 SGV->setAlignment(StructAlign); 440 441 DenseMap<GlobalVariable *, Constant *> Map; 442 Type *I32 = Type::getInt32Ty(Ctx); 443 for (size_t I = 0; I < LocalVars.size(); I++) { 444 GlobalVariable *GV = LocalVars[I]; 445 Constant *GEPIdx[] = {ConstantInt::get(I32, 0), ConstantInt::get(I32, I)}; 446 Constant *GEP = ConstantExpr::getGetElementPtr(LDSTy, SGV, GEPIdx, true); 447 if (IsPaddingField[I]) { 448 assert(GV->use_empty()); 449 GV->eraseFromParent(); 450 } else { 451 Map[GV] = GEP; 452 } 453 } 454 assert(Map.size() == LDSVarsToTransform.size()); 455 return std::make_tuple(SGV, std::move(Map)); 456 } 457 458 template <typename PredicateTy> 459 void replaceLDSVariablesWithStruct( 460 Module &M, std::vector<GlobalVariable *> const &LDSVarsToTransform, 461 GlobalVariable *SGV, 462 DenseMap<GlobalVariable *, Constant *> &LDSVarsToConstantGEP, 463 PredicateTy Predicate) { 464 LLVMContext &Ctx = M.getContext(); 465 const DataLayout &DL = M.getDataLayout(); 466 467 // Create alias.scope and their lists. Each field in the new structure 468 // does not alias with all other fields. 469 SmallVector<MDNode *> AliasScopes; 470 SmallVector<Metadata *> NoAliasList; 471 const size_t NumberVars = LDSVarsToTransform.size(); 472 if (NumberVars > 1) { 473 MDBuilder MDB(Ctx); 474 AliasScopes.reserve(NumberVars); 475 MDNode *Domain = MDB.createAnonymousAliasScopeDomain(); 476 for (size_t I = 0; I < NumberVars; I++) { 477 MDNode *Scope = MDB.createAnonymousAliasScope(Domain); 478 AliasScopes.push_back(Scope); 479 } 480 NoAliasList.append(&AliasScopes[1], AliasScopes.end()); 481 } 482 483 // Replace uses of ith variable with a constantexpr to the corresponding 484 // field of the instance that will be allocated by AMDGPUMachineFunction 485 for (size_t I = 0; I < NumberVars; I++) { 486 GlobalVariable *GV = LDSVarsToTransform[I]; 487 Constant *GEP = LDSVarsToConstantGEP[GV]; 488 489 GV->replaceUsesWithIf(GEP, Predicate); 490 if (GV->use_empty()) { 491 GV->eraseFromParent(); 492 } 493 494 APInt APOff(DL.getIndexTypeSizeInBits(GEP->getType()), 0); 495 GEP->stripAndAccumulateInBoundsConstantOffsets(DL, APOff); 496 uint64_t Offset = APOff.getZExtValue(); 497 498 Align A = commonAlignment(SGV->getAlign().valueOrOne(), Offset); 499 500 if (I) 501 NoAliasList[I - 1] = AliasScopes[I - 1]; 502 MDNode *NoAlias = 503 NoAliasList.empty() ? nullptr : MDNode::get(Ctx, NoAliasList); 504 MDNode *AliasScope = 505 AliasScopes.empty() ? nullptr : MDNode::get(Ctx, {AliasScopes[I]}); 506 507 refineUsesAlignmentAndAA(GEP, A, DL, AliasScope, NoAlias); 508 } 509 } 510 511 void refineUsesAlignmentAndAA(Value *Ptr, Align A, const DataLayout &DL, 512 MDNode *AliasScope, MDNode *NoAlias, 513 unsigned MaxDepth = 5) { 514 if (!MaxDepth || (A == 1 && !AliasScope)) 515 return; 516 517 for (User *U : Ptr->users()) { 518 if (auto *I = dyn_cast<Instruction>(U)) { 519 if (AliasScope && I->mayReadOrWriteMemory()) { 520 MDNode *AS = I->getMetadata(LLVMContext::MD_alias_scope); 521 AS = (AS ? MDNode::getMostGenericAliasScope(AS, AliasScope) 522 : AliasScope); 523 I->setMetadata(LLVMContext::MD_alias_scope, AS); 524 525 MDNode *NA = I->getMetadata(LLVMContext::MD_noalias); 526 NA = (NA ? MDNode::intersect(NA, NoAlias) : NoAlias); 527 I->setMetadata(LLVMContext::MD_noalias, NA); 528 } 529 } 530 531 if (auto *LI = dyn_cast<LoadInst>(U)) { 532 LI->setAlignment(std::max(A, LI->getAlign())); 533 continue; 534 } 535 if (auto *SI = dyn_cast<StoreInst>(U)) { 536 if (SI->getPointerOperand() == Ptr) 537 SI->setAlignment(std::max(A, SI->getAlign())); 538 continue; 539 } 540 if (auto *AI = dyn_cast<AtomicRMWInst>(U)) { 541 // None of atomicrmw operations can work on pointers, but let's 542 // check it anyway in case it will or we will process ConstantExpr. 543 if (AI->getPointerOperand() == Ptr) 544 AI->setAlignment(std::max(A, AI->getAlign())); 545 continue; 546 } 547 if (auto *AI = dyn_cast<AtomicCmpXchgInst>(U)) { 548 if (AI->getPointerOperand() == Ptr) 549 AI->setAlignment(std::max(A, AI->getAlign())); 550 continue; 551 } 552 if (auto *GEP = dyn_cast<GetElementPtrInst>(U)) { 553 unsigned BitWidth = DL.getIndexTypeSizeInBits(GEP->getType()); 554 APInt Off(BitWidth, 0); 555 if (GEP->getPointerOperand() == Ptr) { 556 Align GA; 557 if (GEP->accumulateConstantOffset(DL, Off)) 558 GA = commonAlignment(A, Off.getLimitedValue()); 559 refineUsesAlignmentAndAA(GEP, GA, DL, AliasScope, NoAlias, 560 MaxDepth - 1); 561 } 562 continue; 563 } 564 if (auto *I = dyn_cast<Instruction>(U)) { 565 if (I->getOpcode() == Instruction::BitCast || 566 I->getOpcode() == Instruction::AddrSpaceCast) 567 refineUsesAlignmentAndAA(I, A, DL, AliasScope, NoAlias, MaxDepth - 1); 568 } 569 } 570 } 571 }; 572 573 } // namespace 574 char AMDGPULowerModuleLDS::ID = 0; 575 576 char &llvm::AMDGPULowerModuleLDSID = AMDGPULowerModuleLDS::ID; 577 578 INITIALIZE_PASS(AMDGPULowerModuleLDS, DEBUG_TYPE, 579 "Lower uses of LDS variables from non-kernel functions", false, 580 false) 581 582 ModulePass *llvm::createAMDGPULowerModuleLDSPass() { 583 return new AMDGPULowerModuleLDS(); 584 } 585 586 PreservedAnalyses AMDGPULowerModuleLDSPass::run(Module &M, 587 ModuleAnalysisManager &) { 588 return AMDGPULowerModuleLDS().runOnModule(M) ? PreservedAnalyses::none() 589 : PreservedAnalyses::all(); 590 } 591