[llvm] r336007 - Pass DWARFUnit to verifier by reference not by value. I am moderately

via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 2 09:41:10 PDT 2018


That was my first thought too, but it turns out that doesn't work.  The DWARFUnit owns the DIEs, which haven't been parsed yet, because the verifier is looking to see whether parsing fails.  The parsing requires the unit not to be const.
Passing by value means the DWARFUnit gets copied, all the DIEs are owned by the local copy, then freed when the local copy is destructed.  Passing by reference means it's not copied, the DIEs are owned by the caller's instance, and freed when the caller's instance is destructed; this is in a loop over all units in the section, using a unique_ptr, so I am pretty sure it is still not leaking.
--paulr

From: David Blaikie [mailto:dblaikie at gmail.com]
Sent: Monday, July 02, 2018 12:24 PM
To: Robinson, Paul
Cc: llvm-commits at lists.llvm.org
Subject: Re: [llvm] r336007 - Pass DWARFUnit to verifier by reference not by value. I am moderately

Should that be by const ref? It doesn't seem like a "verify" option should be mutating anything?

On Fri, Jun 29, 2018 at 12:22 PM Paul Robinson via llvm-commits <llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>> wrote:
Author: probinson
Date: Fri Jun 29 12:17:44 2018
New Revision: 336007

URL: http://llvm.org/viewvc/llvm-project?rev=336007&view=rev
Log:
Pass DWARFUnit to verifier by reference not by value.  I am moderately
sure this should not cause a memory leak.

Modified:
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFVerifier.h
    llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFVerifier.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFVerifier.h?rev=336007&r1=336006&r2=336007&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFVerifier.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFVerifier.h Fri Jun 29 12:17:44 2018
@@ -152,7 +152,7 @@ private:
   ///                  type of the unit DIE.
   ///
   /// \returns true if the content is verified successfully, false otherwise.
-  bool verifyUnitContents(DWARFUnit Unit, uint8_t UnitType = 0);
+  bool verifyUnitContents(DWARFUnit &Unit, uint8_t UnitType = 0);

   /// Verify that all Die ranges are valid.
   ///

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp?rev=336007&r1=336006&r2=336007&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFVerifier.cpp Fri Jun 29 12:17:44 2018
@@ -171,7 +171,7 @@ bool DWARFVerifier::verifyUnitHeader(con
   return Success;
 }

-bool DWARFVerifier::verifyUnitContents(DWARFUnit Unit, uint8_t UnitType) {
+bool DWARFVerifier::verifyUnitContents(DWARFUnit &Unit, uint8_t UnitType) {
   uint32_t NumUnitErrors = 0;
   unsigned NumDies = Unit.getNumDIEs();
   for (unsigned I = 0; I < NumDies; ++I) {


_______________________________________________
llvm-commits mailing list
llvm-commits at lists.llvm.org<mailto:llvm-commits at lists.llvm.org>
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180702/74cd37b5/attachment.html>


More information about the llvm-commits mailing list