[PATCH] D40873: [PGO] handle infinite loop properly in pgo instrumention

David Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 6 11:29:03 PST 2017


davidxl added a comment.

What happens is that the call of getAnalysis<LoopInfoWrapperPass>() is invoked after getAnalysis<BlockFrequencyInfoWrapperPass>().  The legacy pass manager in this case will do the analysis run to compute LoopInfo on the fly. Before running the analysis, it will also invoke the 'release' memory method of the analysis passes contained in, in this case is BPI and BFI.    After that we basically have use-after free problem. The leaking is probably just a side effect.

The fix simply fetches the cached LI and BPI from BFI. This is a common pattern used (for getting BPI from BFI).   This is only an issue with the old PM -- as it will go away soon, we don't need to worry about fixing that.


https://reviews.llvm.org/D40873





More information about the llvm-commits mailing list