[Mlir-commits] [mlir] 2a0e051 - [mlir][LLVM] Set cleanup flag on `llvm.landingpad` when exporting to LLVM IR
Markus Böck
llvmlistbot at llvm.org
Mon Jan 3 23:19:52 PST 2022
Author: Markus Böck
Date: 2022-01-04T08:19:26+01:00
New Revision: 2a0e05100c26473b3ce94507200b55f71a9c9482
URL: https://github.com/llvm/llvm-project/commit/2a0e05100c26473b3ce94507200b55f71a9c9482
DIFF: https://github.com/llvm/llvm-project/commit/2a0e05100c26473b3ce94507200b55f71a9c9482.diff
LOG: [mlir][LLVM] Set cleanup flag on `llvm.landingpad` when exporting to LLVM IR
Exporting a llvm.landingpad operation with the cleanup flag set is currently ignored by the export code.
Differential Revision: https://reviews.llvm.org/D116565
Added:
Modified:
mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
mlir/test/Target/LLVMIR/llvmir.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
index 4f5e636c0a8ef..3254aed6c3412 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
@@ -371,6 +371,7 @@ convertOperationImpl(Operation &opInst, llvm::IRBuilderBase &builder,
llvm::Type *ty = moduleTranslation.convertType(lpOp.getType());
llvm::LandingPadInst *lpi =
builder.CreateLandingPad(ty, lpOp.getNumOperands());
+ lpi->setCleanup(lpOp.getCleanup());
// Add clauses
for (llvm::Value *operand :
diff --git a/mlir/test/Target/LLVMIR/llvmir.mlir b/mlir/test/Target/LLVMIR/llvmir.mlir
index e87eebaca5153..6741d51b5f395 100644
--- a/mlir/test/Target/LLVMIR/llvmir.mlir
+++ b/mlir/test/Target/LLVMIR/llvmir.mlir
@@ -1298,31 +1298,29 @@ llvm.func @invokeLandingpad() -> i32 attributes { personality = @__gxx_personali
// -----
-llvm.mlir.global external constant @_ZTIi() : !llvm.ptr<i8>
llvm.func @foo() -> i8
llvm.func @__gxx_personality_v0(...) -> i32
// CHECK-LABEL: @invoke_result
// CHECK-SAME: %[[a0:[0-9]+]]
llvm.func @invoke_result(%arg0 : !llvm.ptr<i8>) attributes { personality = @__gxx_personality_v0 } {
- %0 = llvm.mlir.addressof @_ZTIi : !llvm.ptr<ptr<i8>>
// CHECK: %[[a1:[0-9]+]] = invoke i8 @foo()
// CHECK-NEXT: to label %[[normal:[0-9]+]] unwind label %[[unwind:[0-9]+]]
- %1 = llvm.invoke @foo() to ^bb1 unwind ^bb2 : () -> i8
+ %0 = llvm.invoke @foo() to ^bb1 unwind ^bb2 : () -> i8
// CHECK: [[normal]]:
// CHECK-NEXT: store i8 %[[a1]], i8* %[[a0]]
// CHECK-NEXT: ret void
^bb1:
- llvm.store %1, %arg0 : !llvm.ptr<i8>
+ llvm.store %0, %arg0 : !llvm.ptr<i8>
llvm.return
// CHECK: [[unwind]]:
// CHECK-NEXT: landingpad { i8*, i32 }
-// CHECK-NEXT: catch i8** @_ZTIi
+// CHECK-NEXT: cleanup
// CHECK-NEXT: ret void
^bb2:
- %7 = llvm.landingpad (catch %0 : !llvm.ptr<ptr<i8>>) : !llvm.struct<(ptr<i8>, i32)>
+ %7 = llvm.landingpad cleanup : !llvm.struct<(ptr<i8>, i32)>
llvm.return
}
More information about the Mlir-commits
mailing list