Revert "[amdgpu][nfc] Delete dead code in LowerModuleLDS"
authorJon Chesterfield <jonathanchesterfield@gmail.com>
Sat, 11 Dec 2021 00:30:34 +0000 (00:30 +0000)
committerJon Chesterfield <jonathanchesterfield@gmail.com>
Sat, 11 Dec 2021 00:31:51 +0000 (00:31 +0000)
This reverts commit 7b9ab06d10a6a989f76e6c5ecf89d906f838fe7d.
Said code is better removed as part of a larger change.

llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp

index bb15d0e..894f341 100644 (file)
@@ -55,6 +55,20 @@ static cl::opt<bool> SuperAlignLDSGlobals(
 
 namespace {
 
+SmallPtrSet<GlobalValue *, 32> getUsedList(Module &M) {
+  SmallPtrSet<GlobalValue *, 32> UsedList;
+
+  SmallVector<GlobalValue *, 32> 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;
   }