aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/InlineFunction.cpp
diff options
context:
space:
mode:
authorcynecx <me@cynecx.net>2021-05-13 19:05:11 +0100
committerAmanieu d'Antras <amanieu@gmail.com>2021-05-13 19:13:03 +0100
commit8ec9fd483949ca3b23053effcac226dcc56e7a95 (patch)
treec85cb91a5668b9af25f8e87a1679cf9bb451bef4 /llvm/lib/Transforms/Utils/InlineFunction.cpp
parent9d3eb7885d916b22bc673334f71a10e3b2835174 (diff)
downloadllvm-8ec9fd483949ca3b23053effcac226dcc56e7a95.zip
llvm-8ec9fd483949ca3b23053effcac226dcc56e7a95.tar.gz
llvm-8ec9fd483949ca3b23053effcac226dcc56e7a95.tar.bz2
Support unwinding from inline assembly
I've taken the following steps to add unwinding support from inline assembly: 1) Add a new `unwind` "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 `InlineAsm::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. 6.) Don't allow unwinding callbr. Reviewed By: Amanieu Differential Revision: https://reviews.llvm.org/D95745
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/InlineFunction.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index be4c828..49be8bb 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -45,6 +45,7 @@
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
@@ -545,9 +546,16 @@ static BasicBlock *HandleCallsInBlockInlinedThroughInvoke(
// instructions require no special handling.
CallInst *CI = dyn_cast<CallInst>(I);
- if (!CI || CI->doesNotThrow() || CI->isInlineAsm())
+ if (!CI || CI->doesNotThrow())
continue;
+ if (CI->isInlineAsm()) {
+ InlineAsm *IA = cast<InlineAsm>(CI->getCalledOperand());
+ if (!IA->canThrow()) {
+ continue;
+ }
+ }
+
// We do not need to (and in fact, cannot) convert possibly throwing calls
// to @llvm.experimental_deoptimize (resp. @llvm.experimental.guard) into
// invokes. The caller's "segment" of the deoptimization continuation