[llvm-profdata] Emit Error when Invalid MemOpSize Section is Created by llvm-profdata
authorMatthew Voss <matthew.voss@sony.com>
Thu, 14 Jan 2021 23:31:32 +0000 (15:31 -0800)
committerMatthew Voss <matthew.voss@sony.com>
Tue, 23 Feb 2021 20:51:54 +0000 (12:51 -0800)
commit6da7d3141651ed3ef2b5f369e8ca0eb2e5c66778
tree2f39cef7e952ad30838009ed456f9f935a066e9b
parentf51b3de4e851812b5f7d7c307ddb7b6ec61c05ab
[llvm-profdata] Emit Error when Invalid MemOpSize Section is Created by llvm-profdata

Under certain (currently unknown) conditions, llvm-profdata is outputting
profiles that have two consecutive entries in the MemOPSize section for the
value 0. This causes the PGOMemOPSizeOpt pass to output an invalid switch
instruction with two cases for 0. As mentioned, we’re not quite sure what’s
causing this to happen, but this patch prevents llvm-profdata from outputting a
profile that has this problem and gives an error with a request for a
reproducible.

Differential Revision: https://reviews.llvm.org/D92074
llvm/include/llvm/ProfileData/InstrProf.h
llvm/include/llvm/ProfileData/InstrProfWriter.h
llvm/lib/ProfileData/InstrProf.cpp
llvm/lib/ProfileData/InstrProfWriter.cpp
llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp
llvm/test/Transforms/PGOProfile/Inputs/consecutive-zeros.proftext [new file with mode: 0644]
llvm/test/Transforms/PGOProfile/consecutive-zeros.ll [new file with mode: 0644]
llvm/test/Transforms/PGOProfile/memop_size_opt.ll
llvm/test/tools/llvm-profdata/invalid-profile-gen-zeros.proftext [new file with mode: 0644]
llvm/tools/llvm-profdata/llvm-profdata.cpp