[llvm] [GlobalOpt] Handle operators separately when removing GV users (PR #84694)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 17 23:40:37 PDT 2024


================
@@ -158,12 +158,12 @@ static bool isLeakCheckerRoot(GlobalVariable *GV) {
 /// Given a value that is stored to a global but never read, determine whether
 /// it's safe to remove the store and the chain of computation that feeds the
 /// store.
-static bool IsSafeComputationToRemove(
+static bool isSafeComputationToRemove(
     Value *V, function_ref<TargetLibraryInfo &(Function &)> GetTLI) {
   do {
     if (isa<Constant>(V))
       return true;
-    if (!V->hasOneUse())
+    if (V->getNumUses() > 0)
----------------
efriedma-quic wrote:

hasNUsesOrMore

But also, we have RecursivelyDeleteTriviallyDeadInstructions if you just want to kill off dead computations.  The point of the old code was that it was trying to preserve stores of allocations with other non-trivial uses, which is why it was checking for exactly one use.

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


More information about the llvm-commits mailing list