[PATCH] D15139: [IR] Reformulate LLVM's EH funclet IR

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 1 23:25:21 PST 2015


majnemer created this revision.
majnemer added reviewers: rnk, JosephTremoulet, andrew.w.kaylor.
majnemer added a subscriber: llvm-commits.

While we have successfully implemented a funclet-oriented EH scheme on
top of LLVM IR, our scheme has some notable deficiencies:
- catchendpad and cleanupendpad are necessary in the current design
  but they are difficult to explain to others, even to seasoned LLVM
  experts.
- catchendpad and cleanupendpad are optimization barriers.  They cannot
  be split and force all potentially throwing call-sites to be invokes.
  This has a noticable effect on the quality of our code generation.
- catchpad, while similar in some aspects to invoke, is fairly awkward.
  It is unsplittable, starts a funclet, and has control flow to other
  funclets.
- The nesting relationship between funclets is currently a property of
  control flow edges.  Because of this, we are forced to carefully
  analyze the flow graph to see if there might potentially exist illegal
  nesting among funclets.  While we have logic to clone funclets when
  they are illegally nested, it would be nicer if we had a
  representation which forbade them upfront.

Let's clean this up a bit by doing the following:
- Instead, make catchpad more like cleanuppad and landingpad: no control
  flow, just a bunch of simple operands;  catchpad would be splittable.
- Introduce catchswitch, a control flow instruction designed to model
  the constraints of funclet oriented EH.
- Make funclet scoping explicit by having funclet instructions consume
  the token produced by the funclet which contains them.
- Remove catchendpad and cleanupendpad.  Their presence can be inferred
  implicitly using coloring information.

N.B.  The state numbering code for the CLR has been updated but the
veracity of it's output cannot be spoken for.  An expert should take a
look to make sure the results are reasonable.

http://reviews.llvm.org/D15139

Files:
  docs/ExceptionHandling.rst
  docs/LangRef.rst
  include/llvm-c/Core.h
  include/llvm/Analysis/CFG.h
  include/llvm/Bitcode/LLVMBitCodes.h
  include/llvm/CodeGen/WinEHFuncInfo.h
  include/llvm/IR/IRBuilder.h
  include/llvm/IR/InstVisitor.h
  include/llvm/IR/InstrTypes.h
  include/llvm/IR/Instruction.def
  include/llvm/IR/Instruction.h
  include/llvm/IR/Instructions.h
  include/llvm/Transforms/Utils/Local.h
  lib/Analysis/CFG.cpp
  lib/Analysis/CaptureTracking.cpp
  lib/Analysis/InstructionSimplify.cpp
  lib/Analysis/ScalarEvolutionExpander.cpp
  lib/Analysis/ValueTracking.cpp
  lib/AsmParser/LLLexer.cpp
  lib/AsmParser/LLParser.cpp
  lib/AsmParser/LLParser.h
  lib/AsmParser/LLToken.h
  lib/Bitcode/Reader/BitcodeReader.cpp
  lib/Bitcode/Writer/BitcodeWriter.cpp
  lib/CodeGen/AsmPrinter/WinException.cpp
  lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
  lib/CodeGen/TargetLoweringBase.cpp
  lib/CodeGen/WinEHPrepare.cpp
  lib/IR/AsmWriter.cpp
  lib/IR/Dominators.cpp
  lib/IR/Instruction.cpp
  lib/IR/Instructions.cpp
  lib/IR/Verifier.cpp
  lib/Target/X86/X86WinEHState.cpp
  lib/Transforms/Instrumentation/MemorySanitizer.cpp
  lib/Transforms/Scalar/Reassociate.cpp
  lib/Transforms/Scalar/SCCP.cpp
  lib/Transforms/Utils/CodeExtractor.cpp
  lib/Transforms/Utils/InlineFunction.cpp
  lib/Transforms/Utils/LCSSA.cpp
  lib/Transforms/Utils/Local.cpp
  lib/Transforms/Utils/SimplifyCFG.cpp
  test/Assembler/invalid-OperatorConstraint.ll
  test/Bitcode/compatibility.ll
  test/CodeGen/WinEH/wineh-cloning.ll
  test/CodeGen/WinEH/wineh-coreclr.ll
  test/CodeGen/WinEH/wineh-demotion.ll
  test/CodeGen/WinEH/wineh-exceptionpointer.ll
  test/CodeGen/WinEH/wineh-intrinsics.ll
  test/CodeGen/WinEH/wineh-multi-parent-cloning.ll
  test/CodeGen/WinEH/wineh-no-demotion.ll
  test/CodeGen/WinEH/wineh-statenumbering-cleanups.ll
  test/CodeGen/WinEH/wineh-statenumbering.ll
  test/CodeGen/X86/catchpad-realign-savexmm.ll
  test/CodeGen/X86/catchpad-regmask.ll
  test/CodeGen/X86/catchpad-weight.ll
  test/CodeGen/X86/catchret-empty-fallthrough.ll
  test/CodeGen/X86/catchret-fallthrough.ll
  test/CodeGen/X86/cleanuppad-inalloca.ll
  test/CodeGen/X86/cleanuppad-large-codemodel.ll
  test/CodeGen/X86/cleanuppad-realign.ll
  test/CodeGen/X86/funclet-layout.ll
  test/CodeGen/X86/late-address-taken.ll
  test/CodeGen/X86/seh-catch-all-win32.ll
  test/CodeGen/X86/seh-catch-all.ll
  test/CodeGen/X86/seh-catchpad.ll
  test/CodeGen/X86/seh-except-finally.ll
  test/CodeGen/X86/seh-exception-code.ll
  test/CodeGen/X86/seh-finally.ll
  test/CodeGen/X86/seh-safe-div-win32.ll
  test/CodeGen/X86/seh-safe-div.ll
  test/CodeGen/X86/seh-stack-realign.ll
  test/CodeGen/X86/tail-dup-catchret.ll
  test/CodeGen/X86/tail-merge-wineh.ll
  test/CodeGen/X86/win-catchpad-csrs.ll
  test/CodeGen/X86/win-catchpad-nested-cxx.ll
  test/CodeGen/X86/win-catchpad-nested.ll
  test/CodeGen/X86/win-catchpad-varargs.ll
  test/CodeGen/X86/win-catchpad.ll
  test/CodeGen/X86/win-cleanuppad.ll
  test/CodeGen/X86/win-funclet-cfi.ll
  test/CodeGen/X86/win-mixed-ehpersonality.ll
  test/CodeGen/X86/win32-eh-states.ll
  test/CodeGen/X86/win32-eh.ll
  test/CodeGen/X86/win32-seh-catchpad-realign.ll
  test/CodeGen/X86/win32-seh-catchpad.ll
  test/CodeGen/X86/win32-seh-cleanupendpad.ll
  test/CodeGen/X86/wineh-coreclr.ll
  test/CodeGen/X86/wineh-exceptionpointer.ll
  test/Feature/exception.ll
  test/Transforms/CodeGenPrepare/catchpad-phi-cast.ll
  test/Transforms/GVN/funclet.ll
  test/Transforms/GVN/pre-load.ll
  test/Transforms/Inline/PR25155.ll
  test/Transforms/InstCombine/token.ll
  test/Transforms/LoopStrengthReduce/funclet.ll
  test/Transforms/LoopStrengthReduce/pr25541.ll
  test/Transforms/SimplifyCFG/empty-cleanuppad.ll
  test/Transforms/SimplifyCFG/wineh-unreachable.ll
  test/Verifier/invalid-eh.ll
  tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15139.41591.patch
Type: text/x-patch
Size: 511283 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151202/f4881086/attachment-0001.bin>


More information about the llvm-commits mailing list