[all-commits] [llvm/llvm-project] a0ffe2: [PGO] Skip if an IndirectBrInst critical edge cann...

Fangrui Song via All-commits all-commits at lists.llvm.org
Thu Sep 10 11:04:36 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: a0ffe2b21a5159f3f8eed8e98e488e723aa7cab3
      https://github.com/llvm/llvm-project/commit/a0ffe2b21a5159f3f8eed8e98e488e723aa7cab3
  Author: Fangrui Song <i at maskray.me>
  Date:   2020-09-10 (Thu, 10 Sep 2020)

  Changed paths:
    M llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
    M llvm/test/Transforms/PGOProfile/split-indirectbr-critical-edges.ll

  Log Message:
  -----------
  [PGO] Skip if an IndirectBrInst critical edge cannot be split

PGOInstrumentation runs `SplitIndirectBrCriticalEdges` but some IndirectBrInst
critical edge cannot be split. `getInstrBB` will crash when calling `SplitCriticalEdge`, e.g.

  int foo(char *p) {
    void *targets[2];
    targets[0] = &&indirect;
    targets[1] = &&end;
    for (;; p++)
      if (*p == 7) {
  indirect:
        goto *targets[p[1]]; // the self loop is critical in -O
      }
  end:
    return 0;
  }

Skip such critical edges to prevent a crash.

Reviewed By: davidxl, lebedev.ri

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




More information about the All-commits mailing list