[PGO] Change a `NumVSites == 0` workaround to assert

The root cause was fixed by 3d6f53018f.
The workaround added in 99ad956fda can be changed
to an assert now. (In case the fix regresses, there will be a heap-use-after-free.)
This commit is contained in:
Fangrui Song 2020-08-03 10:09:51 -07:00
parent ac82b918c7
commit 317e00dc54
1 changed files with 3 additions and 2 deletions

View File

@ -6,6 +6,7 @@
|*
\*===----------------------------------------------------------------------===*/
#include <assert.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
@ -93,8 +94,8 @@ static int allocateValueProfileCounters(__llvm_profile_data *Data) {
for (VKI = IPVK_First; VKI <= IPVK_Last; ++VKI)
NumVSites += Data->NumValueSites[VKI];
if (NumVSites == 0)
return 0;
// If NumVSites = 0, calloc is allowed to return a non-null pointer.
assert(NumVSites > 0 && "NumVSites can't be zero");
ValueProfNode **Mem =
(ValueProfNode **)calloc(NumVSites, sizeof(ValueProfNode *));
if (!Mem)