[Lldb-commits] [lldb] r339051 - [IRMemoryMap] Avoid redundant zero-init in the Allocation constructor (NFC)

Vedant Kumar via lldb-commits lldb-commits at lists.llvm.org
Mon Aug 6 13:13:53 PDT 2018


Author: vedantk
Date: Mon Aug  6 13:13:52 2018
New Revision: 339051

URL: http://llvm.org/viewvc/llvm-project?rev=339051&view=rev
Log:
[IRMemoryMap] Avoid redundant zero-init in the Allocation constructor (NFC)

In the lldb-bench/arithmetic benchmark, 1.7% of the total running time
is spent zero-initializing a std::vector that has already been zeroed.

Modified:
    lldb/trunk/include/lldb/Utility/DataBufferHeap.h
    lldb/trunk/source/Expression/IRMemoryMap.cpp

Modified: lldb/trunk/include/lldb/Utility/DataBufferHeap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/DataBufferHeap.h?rev=339051&r1=339050&r2=339051&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/DataBufferHeap.h (original)
+++ lldb/trunk/include/lldb/Utility/DataBufferHeap.h Mon Aug  6 13:13:52 2018
@@ -90,7 +90,8 @@ public:
   /// Set the number of bytes in the data buffer.
   ///
   /// Sets the number of bytes that this object should be able to contain.
-  /// This can be used prior to copying data into the buffer.
+  /// This can be used prior to copying data into the buffer. Note that this
+  /// zero-initializes up to \p byte_size bytes.
   ///
   /// @param[in] byte_size
   ///     The new size in bytes that this data buffer should attempt

Modified: lldb/trunk/source/Expression/IRMemoryMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRMemoryMap.cpp?rev=339051&r1=339050&r2=339051&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRMemoryMap.cpp (original)
+++ lldb/trunk/source/Expression/IRMemoryMap.cpp Mon Aug  6 13:13:52 2018
@@ -278,15 +278,11 @@ IRMemoryMap::Allocation::Allocation(lldb
   default:
     assert(0 && "We cannot reach this!");
   case eAllocationPolicyHostOnly:
+  case eAllocationPolicyMirror:
     m_data.SetByteSize(size);
-    memset(m_data.GetBytes(), 0, size);
     break;
   case eAllocationPolicyProcessOnly:
     break;
-  case eAllocationPolicyMirror:
-    m_data.SetByteSize(size);
-    memset(m_data.GetBytes(), 0, size);
-    break;
   }
 }
 




More information about the lldb-commits mailing list