Initialize all bytes in vp data (msan error)
authorXinliang David Li <davidxl@google.com>
Tue, 15 Dec 2015 21:57:08 +0000 (21:57 +0000)
committerXinliang David Li <davidxl@google.com>
Tue, 15 Dec 2015 21:57:08 +0000 (21:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255680 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ProfileData/InstrProf.cpp

index 723408b1c2ad4f89fa25026aa4d408d72a2f5beb..00c9057c8b45bf9437bbb0cc653202a78db7482e 100644 (file)
@@ -211,8 +211,10 @@ uint64_t stringToHash(uint32_t ValueKind, uint64_t Value) {
 }
 
 ValueProfData *allocValueProfDataInstrProf(size_t TotalSizeInBytes) {
-  return (ValueProfData *)(new (::operator new(TotalSizeInBytes))
-                               ValueProfData());
+  ValueProfData *VD =
+      (ValueProfData *)(new (::operator new(TotalSizeInBytes)) ValueProfData());
+  memset(VD, 0, TotalSizeInBytes);
+  return VD;
 }
 
 static ValueProfRecordClosure InstrProfRecordClosure = {
@@ -223,8 +225,7 @@ static ValueProfRecordClosure InstrProfRecordClosure = {
     getNumValueDataForSiteInstrProf,
     stringToHash,
     getValueForSiteInstrProf,
-    allocValueProfDataInstrProf
-};
+    allocValueProfDataInstrProf};
 
 // Wrapper implementation using the closure mechanism.
 uint32_t ValueProfData::getSize(const InstrProfRecord &Record) {