[PATCH] D21109: IR: Call dropAllReferences from GlobalVariable's destructor.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 7 17:09:32 PDT 2016


pcc created this revision.
pcc added reviewers: dexonsmith, aprantl, mehdi_amini.
pcc added a subscriber: llvm-commits.

We were previously failing to do this and as a result failing to drop
attached metadata.

Not sure if there's a good way to test this. An in-progress patch exposed this
problem by allocating a GlobalVariable at the same address as a previously
allocated GlobalVariable.

http://reviews.llvm.org/D21109

Files:
  include/llvm/IR/GlobalVariable.h

Index: include/llvm/IR/GlobalVariable.h
===================================================================
--- include/llvm/IR/GlobalVariable.h
+++ include/llvm/IR/GlobalVariable.h
@@ -65,6 +65,8 @@
                  bool isExternallyInitialized = false);
 
   ~GlobalVariable() override {
+    dropAllReferences();
+
     // FIXME: needed by operator delete
     setGlobalVariableNumOperands(1);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21109.59977.patch
Type: text/x-patch
Size: 403 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160608/3f31edeb/attachment.bin>


More information about the llvm-commits mailing list