[PATCH] D89911: [PartialInliner]: Handle code regions in a switch stmt cases

Ettore Tiotto via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 21 14:26:35 PDT 2020


etiotto created this revision.
etiotto added reviewers: Whitney, bmahjour.
Herald added subscribers: llvm-commits, hiraditya, kristof.beyls.
Herald added a project: LLVM.
etiotto requested review of this revision.

Currently the following C example fails to be partially inlined. The issue is that `computeOutliningColdRegionsInfo` checks for candidate blocks that have a single entry, but blocks that dominate only themselves fail the check. Example:

  int callee(int c1, int c2) {
    int rc = 0;
  
    switch(c1) {
    case 0: // cold
      rc = 1;
      break;
    case 1: // warm
      rc = 2;
      break;
    case 2: // cold
      rc = 4;
      break;
    default: //hot
      rc = c2;
    }
  
    return rc;
  }
  
  int caller(int c1) {
    int rc = callee(c1, c1);
    return rc;
  }

With this patch the code in the 2 cold switch cases will be outlined and the remaining function inlined in its caller.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89911

Files:
  llvm/lib/Transforms/IPO/PartialInlining.cpp
  llvm/test/Transforms/PartialInlining/switch_stmt.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89911.299804.patch
Type: text/x-patch
Size: 5297 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201021/9970e148/attachment.bin>


More information about the llvm-commits mailing list