[PGO] Fix PGO use ICE when there are unreachable BBs
authorRong Xu <xur@google.com>
Fri, 2 Dec 2016 19:10:29 +0000 (19:10 +0000)
committerRong Xu <xur@google.com>
Fri, 2 Dec 2016 19:10:29 +0000 (19:10 +0000)
commita5b5745a6239df223d55bbf28e83ac5e65b78f56
tree2c6e1ff9fb8d5299fe72fd9393a130b01bf3f7b5
parent5419861a527820cd2f1fe1d10137ead1cd9ff346
[PGO] Fix PGO use ICE when there are unreachable BBs

For -O0 there might be unreachable BBs, which breaks the assumption that all the
BBs have an auxiliary data structure.  In this patch, we add another interface
called findBBInfo() so that a nullptr can be returned for the unreachable BBs
(and the callers can ignore those BBs).

This fixes the bug reported
https://llvm.org/bugs/show_bug.cgi?id=31209

Differential Revision: https://reviews.llvm.org/D27280

llvm-svn: 288528
llvm/lib/Transforms/Instrumentation/CFGMST.h
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/test/Transforms/PGOProfile/Inputs/unreachable_bb.proftext [new file with mode: 0644]
llvm/test/Transforms/PGOProfile/unreachable_bb.ll [new file with mode: 0644]