[PATCH] D156618: fix memory leak in Function::dropAllReferences()

Liqiang Tao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 30 07:19:24 PDT 2023


taolq created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
taolq requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156618

Files:
  llvm/lib/IR/Function.cpp


Index: llvm/lib/IR/Function.cpp
===================================================================
--- llvm/lib/IR/Function.cpp
+++ llvm/lib/IR/Function.cpp
@@ -538,8 +538,10 @@
 
   // Drop uses of any optional data (real or placeholder).
   if (getNumOperands()) {
-    User::dropAllReferences();
-    setNumHungOffUseOperands(0);
+    auto *CPN = ConstantPointerNull::get(Type::getInt1PtrTy(getContext(), 0));
+    Op<0>().set(CPN);
+    Op<1>().set(CPN);
+    Op<2>().set(CPN);
     setValueSubclassData(getSubclassDataFromValue() & ~0xe);
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156618.545438.patch
Type: text/x-patch
Size: 552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230730/779187ff/attachment.bin>


More information about the llvm-commits mailing list