Fix a crash when gathering value profile data on i386 Darwin.
The Darwin linker shrinks sections containing aligned structures when
padding is not explicitly added to the end of the structure. When
iterating over these structures, be sure to not walk past the end of the
section.
No tests added, since running `ninja check-profile` on i386 Darwin is
enough to reproduce the original crash.
llvm-svn: 261683
const __llvm_profile_data *DataBegin = __llvm_profile_begin_data();
const __llvm_profile_data *DataEnd = __llvm_profile_end_data();
const __llvm_profile_data *DI;
- for (DI = DataBegin; DI != DataEnd; ++DI) {
+ for (DI = DataBegin; DI < DataEnd; ++DI) {
uint64_t CurrentVSiteCount = 0;
uint32_t VKI, i;
if (!DI->Values)
* Compute the total Size of the buffer to hold ValueProfData
* structures for functions with value profile data.
*/
- for (I = (__llvm_profile_data *)DataBegin; I != DataEnd; ++I) {
+ for (I = (__llvm_profile_data *)DataBegin; I < DataEnd; ++I) {
ValueProfRuntimeRecord R;
if (initializeValueProfRuntimeRecord(&R, I->NumValueSites, I->Values))
PROF_OOM_RETURN("Failed to write value profile data ");