From 86caf517bf056685cd1b63817967987662d7247f Mon Sep 17 00:00:00 2001 From: Jon Chesterfield Date: Sat, 11 Dec 2021 00:30:34 +0000 Subject: [PATCH] Revert "[amdgpu][nfc] Delete dead code in LowerModuleLDS" This reverts commit 7b9ab06d10a6a989f76e6c5ecf89d906f838fe7d. Said code is better removed as part of a larger change. --- llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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; } -- 2.7.4