1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00
llvm-mirror/test/Transforms/InstCombine/unwind-inline-asm.ll
cynecx 729fe8041c 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
2021-05-13 19:13:03 +01:00

39 lines
1.0 KiB
LLVM

; RUN: opt < %s -O2 -S | FileCheck %s
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@.str.2 = private unnamed_addr constant [7 x i8] c"Boom!\0A\00", align 1
define dso_local void @trap() {
entry:
unreachable
}
define dso_local void @test() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
entry:
; CHECK: define dso_local void @test()
; CHECK-NEXT: entry:
; CHECK-NEXT: invoke void asm sideeffect unwind
invoke void asm sideeffect unwind "call trap", "~{dirflag},~{fpsr},~{flags}"()
to label %invoke.cont unwind label %lpad
invoke.cont:
ret void
lpad:
; CHECK: %0 = landingpad { i8*, i32 }
; CHECK: resume { i8*, i32 } %0
%0 = landingpad { i8*, i32 }
cleanup
call void (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
resume { i8*, i32 } %0
}
declare dso_local i32 @__gxx_personality_v0(...)
declare dso_local void @printf(i8*, ...)