[llvm] [DirectX] Eliminate resource global variables from module (PR #114105)

Greg Roth via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 4 10:29:27 PST 2024


================
@@ -204,6 +204,22 @@ class OpLowerer {
     CleanupCasts.clear();
   }
 
+  // Remove the resource global associated with the handleFromBinding call
+  // instruction and their uses as they aren't needed anymore.
+  void removeResourceGlobals(CallInst *CI) {
+    for (User *User : make_early_inc_range(CI->users())) {
+      if (StoreInst *Store = dyn_cast<StoreInst>(User)) {
+        Value *V = Store->getOperand(1);
+        Store->eraseFromParent();
+        if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V))
+          if (GV->use_empty()) {
----------------
pow2clk wrote:

Done.

https://github.com/llvm/llvm-project/pull/114105


More information about the llvm-commits mailing list