[llvm] [SCCP] Remove LoadInst if it loaded from Constant GlobalVariable  (PR #107245)
    Nikita Popov via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Thu Sep  5 05:42:58 PDT 2024
    
    
  
================
@@ -356,9 +356,13 @@ static bool runIPSCCP(
       continue;
     LLVM_DEBUG(dbgs() << "Found that GV '" << GV->getName()
                       << "' is constant!\n");
-    while (!GV->use_empty()) {
-      StoreInst *SI = cast<StoreInst>(GV->user_back());
-      SI->eraseFromParent();
+    for (User *U : make_early_inc_range(GV->users())) {
+      // We can remove LoadInst at here, because we already replace user of this
+      // to constant.
----------------
nikic wrote:
```suggestion
      // We can remove LoadInst here, because we already replaced its users
      // with a constant.
```
https://github.com/llvm/llvm-project/pull/107245
    
    
More information about the llvm-commits
mailing list