From: Jon Chesterfield Date: Sat, 11 Dec 2021 00:30:34 +0000 (+0000) Subject: Revert "[amdgpu][nfc] Delete dead code in LowerModuleLDS" X-Git-Tag: upstream/15.0.7~23330 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=86caf517bf056685cd1b63817967987662d7247f;p=platform%2Fupstream%2Fllvm.git Revert "[amdgpu][nfc] Delete dead code in LowerModuleLDS" This reverts commit 7b9ab06d10a6a989f76e6c5ecf89d906f838fe7d. Said code is better removed as part of a larger change. --- diff --git a/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp b/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp index bb15d0e..894f341 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp @@ -55,6 +55,20 @@ static cl::opt SuperAlignLDSGlobals( namespace { +SmallPtrSet getUsedList(Module &M) { + SmallPtrSet UsedList; + + SmallVector TmpVec; + collectUsedGlobalVariables(M, TmpVec, true); + UsedList.insert(TmpVec.begin(), TmpVec.end()); + + TmpVec.clear(); + collectUsedGlobalVariables(M, TmpVec, false); + UsedList.insert(TmpVec.begin(), TmpVec.end()); + + return UsedList; +} + class AMDGPULowerModuleLDS : public ModulePass { static void removeFromUsedList(Module &M, StringRef Name, @@ -151,6 +165,8 @@ public: } bool runOnModule(Module &M) override { + UsedList = getUsedList(M); + bool Changed = processUsedLDS(M); for (Function &F : M.functions()) { @@ -163,6 +179,7 @@ public: Changed |= processUsedLDS(M, &F); } + UsedList.clear(); return Changed; }