[PATCH] D95745: Support unwinding from inline assembly

Paul via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 30 11:20:19 PST 2021


cynecx created this revision.
cynecx added reviewers: LLVM, clang.
cynecx added projects: LLVM, clang.
Herald added a reviewer: deadalnix.
Herald added subscribers: dexonsmith, hiraditya.
cynecx requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, aheejin.

I haven't received any feedback about the approach I've taken yet (https://lists.llvm.org/pipermail/llvm-dev/2021-January/148175.html).
So I thought I'd try my luck here.

A splitted patchset can be found here: https://github.com/cynecx/llvm-project/commits/invokeasm2

I've taken the following steps to add support to unwinding from inline assembly:

1. Add a new `canThrow` "attribute" (like `sideeffect`) to the asm syntax:

  invoke void asm sideeffect unwind "call thrower", "~{dirflag},~{fpsr},~{flags}"()
      to label %exit unwind label %uexit

2.) Add Bitcode writing/reading support + LLVM-IR parsing.

3.) Emit EHLabels around inline assembly lowering (SelectionDAGBuilder + GlobalISel) when canThrow is enabled.

4.) Tweak InstCombineCalls/InlineFunction pass to not mark inline assembly "calls" as nounwind.

5.) Add clang support by introducing a new clobber: "unwind", which lower to the `canThrow` being enabled.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95745

Files:
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/Sema/SemaStmtAsm.cpp
  llvm/bindings/go/llvm/ir.go
  llvm/include/llvm-c/Core.h
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/InlineAsm.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/ConstantsContext.h
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/InlineAsm.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/Utils/InlineFunction.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95745.320317.patch
Type: text/x-patch
Size: 27925 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210130/7138d717/attachment-0001.bin>


More information about the cfe-commits mailing list