[llvm-profgen] Fix index out of bounds error while using ip.advance
authorwlei <wlei@fb.com>
Fri, 5 Nov 2021 03:51:04 +0000 (20:51 -0700)
committerwlei <wlei@fb.com>
Sat, 6 Nov 2021 01:38:40 +0000 (18:38 -0700)
commit5bf191a381bba84edc791710e914147de23691dd
treeba4be992cb27b08095511580214969b77dd6a4bb
parent845561ec9d009445c99b51b61810b57bb03e1303
[llvm-profgen] Fix index out of bounds error while using ip.advance

Previously we assume there're some non-executing sections at the bottom of the text section so that we won't hit the array's bound. But on BOLTed binary, it turned out .bolt section is at the bottom of text section which can be profiled, then it crash llvm-profgen. This change try to fix it.

Reviewed By: hoy, wenlei

Differential Revision: https://reviews.llvm.org/D113238
llvm/test/tools/llvm-profgen/Inputs/out-of-bounds.raw.prof [new file with mode: 0644]
llvm/test/tools/llvm-profgen/inline-noprobe.test
llvm/tools/llvm-profgen/ProfileGenerator.cpp
llvm/tools/llvm-profgen/ProfiledBinary.cpp
llvm/tools/llvm-profgen/ProfiledBinary.h