Skip to content

Commit 38ab791

Browse files
authored
Revert "[MLIR] Allow llvm.resume with non-landingpad input (#8590)" (#8910)
This reverts commit af822e2.
1 parent 57ecdeb commit 38ab791

File tree

3 files changed

+3
-48
lines changed

3 files changed

+3
-48
lines changed

mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,21 +1523,8 @@ LogicalResult ReturnOp::verify() {
15231523
//===----------------------------------------------------------------------===//
15241524

15251525
LogicalResult ResumeOp::verify() {
1526-
auto parentFunc = getOperation()->getParentOfType<FunctionOpInterface>();
1527-
assert(parentFunc && "Expecting parent function");
1528-
const auto ty = getOperand().getType();
1529-
if (!parentFunc
1530-
->walk([ty](LandingpadOp landingpad) {
1531-
return landingpad.getType() == ty
1532-
? WalkResult::interrupt() // Just an operation needed
1533-
: WalkResult::advance();
1534-
})
1535-
.wasInterrupted()) {
1536-
// No operation was found: emit error
1537-
return emitOpError("expects landingpad operation in the same function and "
1538-
"with the same type as this operation's operand");
1539-
}
1540-
1526+
if (!getValue().getDefiningOp<LandingpadOp>())
1527+
return emitOpError("expects landingpad value as operand");
15411528
// No check for personality of function - landingpad op verifies it.
15421529
return success();
15431530
}

mlir/test/Dialect/LLVMIR/invalid.mlir

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -798,18 +798,7 @@ llvm.func @caller(%arg0: i32) -> i32 attributes { personality = @__gxx_personali
798798
llvm.return %0 : i32
799799
^bb2: // pred: ^bb0
800800
%2 = llvm.landingpad cleanup : !llvm.struct<(ptr, i32)>
801-
// expected-error@+1 {{'llvm.resume' op expects landingpad operation in the same function and with the same type as this operation's operand}}
802-
llvm.resume %0 : i32
803-
}
804-
805-
// -----
806-
807-
llvm.func @foo(i32) -> i32
808-
llvm.func @__gxx_personality_v0(...) -> i32
809-
810-
llvm.func @caller(%arg0: i32) -> i32 attributes { personality = @__gxx_personality_v0 } {
811-
%0 = llvm.mlir.constant(1 : i32) : i32
812-
// expected-error@+1 {{'llvm.resume' op expects landingpad operation in the same function and with the same type as this operation's operand}}
801+
// expected-error@+1 {{'llvm.resume' op expects landingpad value as operand}}
813802
llvm.resume %0 : i32
814803
}
815804

mlir/test/Dialect/LLVMIR/roundtrip.mlir

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -427,27 +427,6 @@ llvm.func @invokeLandingpad() -> i32 attributes { personality = @__gxx_personali
427427
llvm.return %0 : i32
428428
}
429429

430-
llvm.func @foo2() -> !llvm.struct<(ptr<i8>, i32)>
431-
432-
// CHECK-LABEL: llvm.func @resumeNoLandingpadValue(
433-
// CHECK-SAME: %[[ARG:.*]]: i32)
434-
llvm.func @resumeNoLandingpadValue(%arg0: i32) -> i32 attributes { personality = @__gxx_personality_v0 } {
435-
// CHECK: %[[VAL_0:.*]] = llvm.call @foo2() : () -> !llvm.struct<(ptr<i8>, i32)>
436-
// CHECK: %[[VAL_1:.*]] = llvm.invoke @foo(%[[ARG]]) to ^[[BB1:.*]] unwind ^[[BB2:.*]] : (i32) -> i32
437-
%0 = llvm.call @foo2() : () -> !llvm.struct<(ptr<i8>, i32)>
438-
%1 = llvm.invoke @foo(%arg0) to ^bb1 unwind ^bb2 : (i32) -> i32
439-
// CHECK: ^[[BB1]]:
440-
// CHECK: llvm.return %[[VAL_1]] : i32
441-
^bb1: // pred: ^bb0
442-
llvm.return %1 : i32
443-
// CHECK: ^[[BB2]]:
444-
// CHECK: %[[VAL_2:.*]] = llvm.landingpad cleanup : !llvm.struct<(ptr<i8>, i32)>
445-
// CHECK: llvm.resume %[[VAL_0]] : !llvm.struct<(ptr<i8>, i32)>
446-
^bb2: // pred: ^bb0
447-
%2 = llvm.landingpad cleanup : !llvm.struct<(ptr<i8>, i32)>
448-
llvm.resume %0 : !llvm.struct<(ptr<i8>, i32)>
449-
}
450-
451430
// CHECK-LABEL: @useFreezeOp
452431
func.func @useFreezeOp(%arg0: i32) {
453432
// CHECK: = llvm.freeze %[[ARG0:.*]] : i32

0 commit comments

Comments
 (0)