Skip to content

Revert "[MLIR] Allow llvm.resume with non-landingpad input (#8590)" #8910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1523,21 +1523,8 @@ LogicalResult ReturnOp::verify() {
//===----------------------------------------------------------------------===//

LogicalResult ResumeOp::verify() {
auto parentFunc = getOperation()->getParentOfType<FunctionOpInterface>();
assert(parentFunc && "Expecting parent function");
const auto ty = getOperand().getType();
if (!parentFunc
->walk([ty](LandingpadOp landingpad) {
return landingpad.getType() == ty
? WalkResult::interrupt() // Just an operation needed
: WalkResult::advance();
})
.wasInterrupted()) {
// No operation was found: emit error
return emitOpError("expects landingpad operation in the same function and "
"with the same type as this operation's operand");
}

if (!getValue().getDefiningOp<LandingpadOp>())
return emitOpError("expects landingpad value as operand");
// No check for personality of function - landingpad op verifies it.
return success();
}
Expand Down
13 changes: 1 addition & 12 deletions mlir/test/Dialect/LLVMIR/invalid.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -798,18 +798,7 @@ llvm.func @caller(%arg0: i32) -> i32 attributes { personality = @__gxx_personali
llvm.return %0 : i32
^bb2: // pred: ^bb0
%2 = llvm.landingpad cleanup : !llvm.struct<(ptr, i32)>
// expected-error@+1 {{'llvm.resume' op expects landingpad operation in the same function and with the same type as this operation's operand}}
llvm.resume %0 : i32
}

// -----

llvm.func @foo(i32) -> i32
llvm.func @__gxx_personality_v0(...) -> i32

llvm.func @caller(%arg0: i32) -> i32 attributes { personality = @__gxx_personality_v0 } {
%0 = llvm.mlir.constant(1 : i32) : i32
// expected-error@+1 {{'llvm.resume' op expects landingpad operation in the same function and with the same type as this operation's operand}}
// expected-error@+1 {{'llvm.resume' op expects landingpad value as operand}}
llvm.resume %0 : i32
}

Expand Down
21 changes: 0 additions & 21 deletions mlir/test/Dialect/LLVMIR/roundtrip.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -427,27 +427,6 @@ llvm.func @invokeLandingpad() -> i32 attributes { personality = @__gxx_personali
llvm.return %0 : i32
}

llvm.func @foo2() -> !llvm.struct<(ptr<i8>, i32)>

// CHECK-LABEL: llvm.func @resumeNoLandingpadValue(
// CHECK-SAME: %[[ARG:.*]]: i32)
llvm.func @resumeNoLandingpadValue(%arg0: i32) -> i32 attributes { personality = @__gxx_personality_v0 } {
// CHECK: %[[VAL_0:.*]] = llvm.call @foo2() : () -> !llvm.struct<(ptr<i8>, i32)>
// CHECK: %[[VAL_1:.*]] = llvm.invoke @foo(%[[ARG]]) to ^[[BB1:.*]] unwind ^[[BB2:.*]] : (i32) -> i32
%0 = llvm.call @foo2() : () -> !llvm.struct<(ptr<i8>, i32)>
%1 = llvm.invoke @foo(%arg0) to ^bb1 unwind ^bb2 : (i32) -> i32
// CHECK: ^[[BB1]]:
// CHECK: llvm.return %[[VAL_1]] : i32
^bb1: // pred: ^bb0
llvm.return %1 : i32
// CHECK: ^[[BB2]]:
// CHECK: %[[VAL_2:.*]] = llvm.landingpad cleanup : !llvm.struct<(ptr<i8>, i32)>
// CHECK: llvm.resume %[[VAL_0]] : !llvm.struct<(ptr<i8>, i32)>
^bb2: // pred: ^bb0
%2 = llvm.landingpad cleanup : !llvm.struct<(ptr<i8>, i32)>
llvm.resume %0 : !llvm.struct<(ptr<i8>, i32)>
}

// CHECK-LABEL: @useFreezeOp
func.func @useFreezeOp(%arg0: i32) {
// CHECK: = llvm.freeze %[[ARG0:.*]] : i32
Expand Down