[all-commits] [llvm/llvm-project] ff7739: [mlir] Added llvm.resume and personality functions...
Shraiysh via All-commits
all-commits at lists.llvm.org
Thu Mar 19 05:14:31 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: ff77397fcf6ef74906b28be435c159706ed60d43
https://github.com/llvm/llvm-project/commit/ff77397fcf6ef74906b28be435c159706ed60d43
Author: Shraiysh Vaishay <cs17btech11050 at iith.ac.in>
Date: 2020-03-19 (Thu, 19 Mar 2020)
Changed paths:
M mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
M mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
M mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
M mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
M mlir/test/Dialect/LLVMIR/invalid.mlir
M mlir/test/Dialect/LLVMIR/roundtrip.mlir
M mlir/test/Target/import.ll
M mlir/test/Target/llvmir.mlir
Log Message:
-----------
[mlir] Added llvm.resume and personality functions in LLVM IR Dialect
`llvm.resume` is similar to `llvm.return` except that has to be exactly
one operand and that should be derived from a `llvm.landingpad`
instruction. Any function having `llvm.landingpad` instruction must
have a personality attribute.
Example:
LLVM IR
```
define dso_local i32 @main() personality i32 (...)* @__gxx_personality_v0 {
invoke void @foo(i32 42)
to label %3 unwind label %1
1: ; preds = %0
%2 = landingpad i8*
catch i8** @_ZTIi
catch i8* bitcast (i8** @_ZTIi to i8*)
resume i8* %2
3: ; preds = %0
ret i32 1
}
```
MLIR - LLVM IR Dialect
```
llvm.func @main() -> !llvm.i32 attributes {personality = @__gxx_personality_v0} {
%0 = llvm.mlir.constant(1 : i32) : !llvm.i32
%1 = llvm.mlir.addressof @_ZTIi : !llvm<"i8**">
%2 = llvm.bitcast %1 : !llvm<"i8**"> to !llvm<"i8*">
%3 = llvm.mlir.addressof @_ZTIi : !llvm<"i8**">
%4 = llvm.mlir.constant(42 : i32) : !llvm.i32
llvm.invoke @foo(%4) to ^bb2 unwind ^bb1 : (!llvm.i32) -> ()
^bb1: // pred: ^bb0
%5 = llvm.landingpad (catch %3 : !llvm<"i8**">) (catch %2 : !llvm<"i8*">) : !llvm<"i8*">
llvm.resume %5 : !llvm<"i8*">
^bb2: // pred: ^bb0
llvm.return %0 : !llvm.i32
}
```
Differential Revision: https://reviews.llvm.org/D71888
More information about the All-commits
mailing list