This is an archive of the discontinued LLVM Phabricator instance.

[HotColdSplit][WIP] Add support for outlining Itanium EH blocks by hoisting calls to eh.typeid.for intrinsic
Needs ReviewPublic

Authored by rjf on Aug 28 2020, 10:03 PM.

Details

Summary

Currently, Hot Cold Splitting does not support outlining exception handling regions.

The difficulties of outlining EH regions are as follows:

  1. We cannot extract the block containing the invoke, otherwise we'll potentially extract the hot branch as well;
  2. We cannot extract the entire landing pad block, since the first instruction after the unwind edge into the lpad block must be the landingpad instruction.
  3. It seems possible to simply split the lpad block into two from the first instruction, and then outling starting from there; this is analogous to issue #4, which we outline below;
  4. The block at catch.dispatch contains potentially a series of calls to the eh.typeid.for intrinsic to use function-specific type information to match if the catch call can go through. As such, CodeExtractor cannot extract these calls (See detailed discussion and example in https://bugs.llvm.org/show_bug.cgi?id=39545). Making typeid.for outlining-friendly seems in general a difficult task, as the proposed patch in 39545 uses an entirely new pass to do so.

What remains is the idea of extracting the typeid.for intrinsic calls to
further up in the control flow graph. Without calls to eh.typeid.for intrinsic,
we can perform outlining safely and store the resultant values in some variable.

To safely implement this strategy, we need to hoist these call instructions to
the highest post-landingpad block that dominates them. Otherwise, incorrect compilation
might happen with cases of nested try/catches.

Empirical evaluation with -Os on Firefox yields the following data:

-Os, EH outlining enabled: 142678 cold regions detected/62985 cold regions outlined, code size: 2.187481424GB

-Os, EH outlining disabled: 142081 cold regions detected/62982 cold regions outlined, code size: 2.188262032 GB

Diff Detail

Event Timeline

rjf created this revision.Aug 28 2020, 10:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 28 2020, 10:03 PM
rjf requested review of this revision.Aug 28 2020, 10:03 PM
rjf added a comment.Aug 28 2020, 10:06 PM

This is marked WIP since it might be better to do the code transformation inside CodeExtractor instead of HotColdSplitting. With HCS, we're currently doing it before code extraction, but the region might end up being unworthy for extraction. But if we do it in CodeExtractor, we'll need another implementation of OutliningRegion to detect the SESE region enclosing the EH blocks.

rjf updated this revision to Diff 288759.Aug 28 2020, 10:11 PM

Update comments.

rjf updated this revision to Diff 288761.Aug 28 2020, 10:23 PM

Add test case for EH outlining

Matt added a subscriber: Matt.Mar 3 2021, 7:06 AM