[all-commits] [llvm/llvm-project] 3b387d: Lift EHPersonalities from Analysis to IR (NFC)

Stefan Gränitz via All-commits all-commits at lists.llvm.org
Fri Jan 27 09:06:15 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 3b387d10707d3ec5f4786812cc055c89c3eaa161
      https://github.com/llvm/llvm-project/commit/3b387d10707d3ec5f4786812cc055c89c3eaa161
  Author: Stefan Gränitz <stefan.graenitz at gmail.com>
  Date:   2023-01-27 (Fri, 27 Jan 2023)

  Changed paths:
    M clang/docs/tools/clang-formatted-files.txt
    R llvm/include/llvm/Analysis/EHPersonalities.h
    M llvm/include/llvm/Analysis/MustExecute.h
    M llvm/include/llvm/CodeGen/MachineFunction.h
    A llvm/include/llvm/IR/EHPersonalities.h
    M llvm/lib/Analysis/CMakeLists.txt
    R llvm/lib/Analysis/EHPersonalities.cpp
    M llvm/lib/Analysis/ValueTracking.cpp
    M llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    M llvm/lib/CodeGen/DwarfEHPrepare.cpp
    M llvm/lib/CodeGen/MachineFunction.cpp
    M llvm/lib/CodeGen/MachineVerifier.cpp
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
    M llvm/lib/CodeGen/StackProtector.cpp
    M llvm/lib/CodeGen/WinEHPrepare.cpp
    M llvm/lib/IR/CMakeLists.txt
    A llvm/lib/IR/EHPersonalities.cpp
    M llvm/lib/Target/M68k/M68kCollapseMOVEMPass.cpp
    M llvm/lib/Target/M68k/M68kExpandPseudo.cpp
    M llvm/lib/Target/X86/X86ExpandPseudo.cpp
    M llvm/lib/Target/X86/X86FrameLowering.cpp
    M llvm/lib/Target/X86/X86ISelLowering.cpp
    M llvm/lib/Target/X86/X86WinEHState.cpp
    M llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
    M llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
    M llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
    M llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
    M llvm/lib/Transforms/ObjCARC/ObjCARC.h
    M llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
    M llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
    M llvm/lib/Transforms/Utils/EscapeEnumerator.cpp
    M llvm/lib/Transforms/Utils/InlineFunction.cpp
    M llvm/lib/Transforms/Utils/Local.cpp
    M llvm/utils/gn/secondary/llvm/lib/Analysis/BUILD.gn
    M llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn

  Log Message:
  -----------
  Lift EHPersonalities from Analysis to IR (NFC)

Computing EH-related information was only relevant for analysis passes so far. Lifting it to IR will allow the IR Verifier to calculate EH funclet coloring and validate funclet operand bundles in a follow-up step.

Reviewed By: rnk, compnerd

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


  Commit: bb4a04e794aadadc411e7e42a661c6d836d9e8a0
      https://github.com/llvm/llvm-project/commit/bb4a04e794aadadc411e7e42a661c6d836d9e8a0
  Author: Stefan Gränitz <stefan.graenitz at gmail.com>
  Date:   2023-01-27 (Fri, 27 Jan 2023)

  Changed paths:
    M llvm/lib/IR/Verifier.cpp
    M llvm/test/Transforms/ObjCARC/invoke-2.ll
    A llvm/test/Verifier/operand-bundles-wineh.ll

  Log Message:
  -----------
  [Verifier][WinEH] Check funclet tokens on intrinsic calls that may lower to function calls

WinEHPrepare requires funclet operand bundles ("tokens") on function calls from EH funclets to prevent them from getting removed as "implausible" calls. This includes calls to intrinsic functions that lower to function calls in the course of IR transformations (e.g. ObjC ARC runtime calls).

We can not detect such cases in WinEHPrepare itself, because at this point they mixed up with valid implausible calls. These must be removed to guarantee that the EH backend can assign unique colors and EH state numbers to all blocks.

This patch allows the IR Verifier to detect missing and dangling funclet tokens. Non-conforming IR becomes illegal and miscompilations are detected early. In order to find funclet pad instructions for funclets that extend over multiple blocks, we have to calculate EH funclet colors. As coloring can be expensive, it runs on-demand and results are cached per function.

Reviewed By: efriedma

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


Compare: https://github.com/llvm/llvm-project/compare/fa639d3b43a9...bb4a04e794aa


More information about the All-commits mailing list