diff options
author | Fangrui Song <i@maskray.me> | 2020-08-03 10:09:51 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2020-08-03 10:14:03 -0700 |
commit | 317e00dc54c74a2e0fd0c62bdc6a6d68b0d2ca7e (patch) | |
tree | a7c118bdd68cc710826873ca63cfacc8f89bc6fb | |
parent | ac82b918c74f3fab8d4a7c1905277bda6b9bccb4 (diff) | |
download | llvm-317e00dc54c74a2e0fd0c62bdc6a6d68b0d2ca7e.tar.gz |
[PGO] Change a `NumVSites == 0` workaround to assert
The root cause was fixed by 3d6f53018f845e893ad34f64ff2851a2e5c3ba1d.
The workaround added in 99ad956fdaee5398fdcf46fa49cb433cf52dc461 can be changed
to an assert now. (In case the fix regresses, there will be a heap-use-after-free.)
-rw-r--r-- | compiler-rt/lib/profile/InstrProfilingValue.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler-rt/lib/profile/InstrProfilingValue.c b/compiler-rt/lib/profile/InstrProfilingValue.c index 29b9e628a9c9..4b4081bd21b7 100644 --- a/compiler-rt/lib/profile/InstrProfilingValue.c +++ b/compiler-rt/lib/profile/InstrProfilingValue.c @@ -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) |