[Mlir-commits] [mlir] 8cf970f - [mlir][llvm][test] Move exception-related tests to their own file

Victor Perez llvmlistbot at llvm.org
Tue Apr 25 07:01:01 PDT 2023


Author: Victor Perez
Date: 2023-04-25T14:59:25+01:00
New Revision: 8cf970faacee61370b7c80265e97872403eb0f4c

URL: https://github.com/llvm/llvm-project/commit/8cf970faacee61370b7c80265e97872403eb0f4c
DIFF: https://github.com/llvm/llvm-project/commit/8cf970faacee61370b7c80265e97872403eb0f4c.diff

LOG: [mlir][llvm][test] Move exception-related tests to their own file

Move mlir-translate exception-related tests from basic.ll to exception.ll.

Signed-off-by: Victor Perez <victor.perez at codeplay.com>

Differential Revision: https://reviews.llvm.org/D149043

Added: 
    mlir/test/Target/LLVMIR/Import/exception.ll

Modified: 
    mlir/test/Target/LLVMIR/Import/basic.ll

Removed: 
    


################################################################################
diff  --git a/mlir/test/Target/LLVMIR/Import/basic.ll b/mlir/test/Target/LLVMIR/Import/basic.ll
index d3eebc0feab8f..19e4543f8010d 100644
--- a/mlir/test/Target/LLVMIR/Import/basic.ll
+++ b/mlir/test/Target/LLVMIR/Import/basic.ll
@@ -53,111 +53,6 @@ if.end:
 }
 ; CHECK-DBG: } loc(#[[MODULELOC]])
 
-
- at _ZTIi = external dso_local constant ptr
- at _ZTIii= external dso_local constant ptr
-declare void @foo(ptr)
-declare ptr @bar(ptr)
-declare i32 @__gxx_personality_v0(...)
-
-; CHECK-LABEL: @invokeLandingpad
-define i32 @invokeLandingpad() personality ptr @__gxx_personality_v0 {
-  ; CHECK: %[[a1:[0-9]+]] = llvm.mlir.addressof @_ZTIii : !llvm.ptr
-  ; CHECK: %[[a3:[0-9]+]] = llvm.alloca %{{[0-9]+}} x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr
-  %1 = alloca i8
-  ; CHECK: llvm.invoke @foo(%[[a3]]) to ^bb2 unwind ^bb1 : (!llvm.ptr) -> ()
-  invoke void @foo(ptr %1) to label %4 unwind label %2
-
-; CHECK: ^bb1:
-  ; CHECK: %{{[0-9]+}} = llvm.landingpad (catch %{{[0-9]+}} : !llvm.ptr) (catch %[[a1]] : !llvm.ptr) (filter %{{[0-9]+}} : !llvm.array<1 x i1>) : !llvm.struct<(ptr, i32)>
-  %3 = landingpad { ptr, i32 } catch ptr @_ZTIi catch ptr @_ZTIii
-          filter [1 x i1] [i1 1]
-  resume { ptr, i32 } %3
-
-; CHECK: ^bb2:
-  ; CHECK: llvm.return %{{[0-9]+}} : i32
-  ret i32 1
-
-; CHECK: ^bb3:
-  ; CHECK: %{{[0-9]+}} = llvm.invoke @bar(%[[a3]]) to ^bb2 unwind ^bb1 : (!llvm.ptr) -> !llvm.ptr
-  %6 = invoke ptr @bar(ptr %1) to label %4 unwind label %2
-
-; CHECK: ^bb4:
-  ; CHECK: llvm.return %{{[0-9]+}} : i32
-  ret i32 0
-}
-
-declare i32 @foo2()
-
-; CHECK-LABEL: @invokePhi
-; CHECK-SAME:            (%[[cond:.*]]: i1) -> i32
-define i32 @invokePhi(i1 %cond) personality ptr @__gxx_personality_v0 {
-entry:
-  ; CHECK: %[[c0:.*]] = llvm.mlir.constant(0 : i32) : i32
-  ; CHECK: llvm.cond_br %[[cond]], ^[[bb1:.*]], ^[[bb2:.*]]
-  br i1 %cond, label %call, label %nocall
-; CHECK: ^[[bb1]]:
-call:
-  ; CHECK: %[[invoke:.*]] = llvm.invoke @foo2() to ^[[bb3:.*]] unwind ^[[bb5:.*]] : () -> i32
-  %invoke = invoke i32 @foo2() to label %bb0 unwind label %bb1
-; CHECK: ^[[bb2]]:
-nocall:
-  ; CHECK: llvm.br ^[[bb4:.*]](%[[c0]] : i32)
-  br label %bb0
-; CHECK: ^[[bb3]]:
-  ; CHECK: llvm.br ^[[bb4]](%[[invoke]] : i32)
-; CHECK: ^[[bb4]](%[[barg:.*]]: i32):
-bb0:
-  %ret = phi i32 [ 0, %nocall ], [ %invoke, %call ]
-  ; CHECK: llvm.return %[[barg]] : i32
-  ret i32 %ret
-; CHECK: ^[[bb5]]:
-bb1:
-  ; CHECK: %[[lp:.*]] = llvm.landingpad cleanup : i32
-  %resume = landingpad i32 cleanup
-  ; CHECK: llvm.resume %[[lp]] : i32
-  resume i32 %resume
-}
-
-; CHECK-LABEL: @invokePhiComplex
-; CHECK-SAME:                   (%[[cond:.*]]: i1) -> i32
-define i32 @invokePhiComplex(i1 %cond) personality ptr @__gxx_personality_v0 {
-entry:
-  ; CHECK: %[[c0:.*]] = llvm.mlir.constant(0 : i32) : i32
-  ; CHECK: %[[c1:.*]] = llvm.mlir.constant(1 : i32) : i32
-  ; CHECK: %[[c2:.*]] = llvm.mlir.constant(2 : i32) : i32
-  ; CHECK: %[[c20:.*]] = llvm.mlir.constant(20 : i32) : i32  
-  ; CHECK: llvm.cond_br %[[cond]], ^[[bb1:.*]], ^[[bb2:.*]]
-  br i1 %cond, label %call, label %nocall
-; CHECK: ^[[bb1]]:
-call:
-  ; CHECK: %[[invoke:.*]] = llvm.invoke @foo2() to ^[[bb3:.*]] unwind ^[[bb5:.*]] : () -> i32
-  %invoke = invoke i32 @foo2() to label %bb0 unwind label %bb1
-; CHECK: ^[[bb2]]:
-nocall:
-  ; CHECK: llvm.br ^[[bb4:.*]](%[[c0]], %[[c1]], %[[c2]] : i32, i32, i32)
-  br label %bb0
-; CHECK: ^[[bb3]]:
-  ; CHECK: llvm.br ^[[bb4]](%[[invoke]], %[[c20]], %[[invoke]] : i32, i32, i32)
-; CHECK: ^[[bb4]](%[[barg0:.*]]: i32, %[[barg1:.*]]: i32, %[[barg2:.*]]: i32):
-bb0:
-  %a = phi i32 [ 0, %nocall ], [ %invoke, %call ]
-  %b = phi i32 [ 1, %nocall ], [ 20, %call ]
-  %c = phi i32 [ 2, %nocall ], [ %invoke, %call ]
-  ; CHECK: %[[add0:.*]] = llvm.add %[[barg0]], %[[barg1]] : i32
-  ; CHECK: %[[add1:.*]] = llvm.add %[[barg2]], %[[add0]] : i32
-  %d = add i32 %a, %b
-  %e = add i32 %c, %d
-  ; CHECK: llvm.return %[[add1]] : i32
-  ret i32 %e
-; CHECK: ^[[bb5]]:
-bb1:
-  ; CHECK: %[[lp:.*]] = llvm.landingpad cleanup : i32
-  %resume = landingpad i32 cleanup
-  ; CHECK: llvm.resume %[[lp]] : i32
-  resume i32 %resume
-}
-
 ; CHECK-LABEL: @hasGCFunction
 ; CHECK-SAME: garbageCollector = "statepoint-example"
 define void @hasGCFunction() gc "statepoint-example" {

diff  --git a/mlir/test/Target/LLVMIR/Import/exception.ll b/mlir/test/Target/LLVMIR/Import/exception.ll
new file mode 100644
index 0000000000000..374f51e06e840
--- /dev/null
+++ b/mlir/test/Target/LLVMIR/Import/exception.ll
@@ -0,0 +1,105 @@
+; RUN: mlir-translate -import-llvm %s | FileCheck %s
+
+ at _ZTIi = external dso_local constant ptr
+ at _ZTIii= external dso_local constant ptr
+declare void @foo(ptr)
+declare ptr @bar(ptr)
+declare i32 @__gxx_personality_v0(...)
+
+; CHECK-LABEL: @invokeLandingpad
+define i32 @invokeLandingpad() personality ptr @__gxx_personality_v0 {
+  ; CHECK: %[[a1:[0-9]+]] = llvm.mlir.addressof @_ZTIii : !llvm.ptr
+  ; CHECK: %[[a3:[0-9]+]] = llvm.alloca %{{[0-9]+}} x i8 {alignment = 1 : i64} : (i32) -> !llvm.ptr
+  %1 = alloca i8
+  ; CHECK: llvm.invoke @foo(%[[a3]]) to ^bb2 unwind ^bb1 : (!llvm.ptr) -> ()
+  invoke void @foo(ptr %1) to label %4 unwind label %2
+
+; CHECK: ^bb1:
+  ; CHECK: %{{[0-9]+}} = llvm.landingpad (catch %{{[0-9]+}} : !llvm.ptr) (catch %[[a1]] : !llvm.ptr) (filter %{{[0-9]+}} : !llvm.array<1 x i1>) : !llvm.struct<(ptr, i32)>
+  %3 = landingpad { ptr, i32 } catch ptr @_ZTIi catch ptr @_ZTIii
+          filter [1 x i1] [i1 1]
+  resume { ptr, i32 } %3
+
+; CHECK: ^bb2:
+  ; CHECK: llvm.return %{{[0-9]+}} : i32
+  ret i32 1
+
+; CHECK: ^bb3:
+  ; CHECK: %{{[0-9]+}} = llvm.invoke @bar(%[[a3]]) to ^bb2 unwind ^bb1 : (!llvm.ptr) -> !llvm.ptr
+  %6 = invoke ptr @bar(ptr %1) to label %4 unwind label %2
+
+; CHECK: ^bb4:
+  ; CHECK: llvm.return %{{[0-9]+}} : i32
+  ret i32 0
+}
+
+declare i32 @foo2()
+
+; CHECK-LABEL: @invokePhi
+; CHECK-SAME:            (%[[cond:.*]]: i1) -> i32
+define i32 @invokePhi(i1 %cond) personality ptr @__gxx_personality_v0 {
+entry:
+  ; CHECK: %[[c0:.*]] = llvm.mlir.constant(0 : i32) : i32
+  ; CHECK: llvm.cond_br %[[cond]], ^[[bb1:.*]], ^[[bb2:.*]]
+  br i1 %cond, label %call, label %nocall
+; CHECK: ^[[bb1]]:
+call:
+  ; CHECK: %[[invoke:.*]] = llvm.invoke @foo2() to ^[[bb3:.*]] unwind ^[[bb5:.*]] : () -> i32
+  %invoke = invoke i32 @foo2() to label %bb0 unwind label %bb1
+; CHECK: ^[[bb2]]:
+nocall:
+  ; CHECK: llvm.br ^[[bb4:.*]](%[[c0]] : i32)
+  br label %bb0
+; CHECK: ^[[bb3]]:
+  ; CHECK: llvm.br ^[[bb4]](%[[invoke]] : i32)
+; CHECK: ^[[bb4]](%[[barg:.*]]: i32):
+bb0:
+  %ret = phi i32 [ 0, %nocall ], [ %invoke, %call ]
+  ; CHECK: llvm.return %[[barg]] : i32
+  ret i32 %ret
+; CHECK: ^[[bb5]]:
+bb1:
+  ; CHECK: %[[lp:.*]] = llvm.landingpad cleanup : i32
+  %resume = landingpad i32 cleanup
+  ; CHECK: llvm.resume %[[lp]] : i32
+  resume i32 %resume
+}
+
+; CHECK-LABEL: @invokePhiComplex
+; CHECK-SAME:                   (%[[cond:.*]]: i1) -> i32
+define i32 @invokePhiComplex(i1 %cond) personality ptr @__gxx_personality_v0 {
+entry:
+  ; CHECK: %[[c0:.*]] = llvm.mlir.constant(0 : i32) : i32
+  ; CHECK: %[[c1:.*]] = llvm.mlir.constant(1 : i32) : i32
+  ; CHECK: %[[c2:.*]] = llvm.mlir.constant(2 : i32) : i32
+  ; CHECK: %[[c20:.*]] = llvm.mlir.constant(20 : i32) : i32  
+  ; CHECK: llvm.cond_br %[[cond]], ^[[bb1:.*]], ^[[bb2:.*]]
+  br i1 %cond, label %call, label %nocall
+; CHECK: ^[[bb1]]:
+call:
+  ; CHECK: %[[invoke:.*]] = llvm.invoke @foo2() to ^[[bb3:.*]] unwind ^[[bb5:.*]] : () -> i32
+  %invoke = invoke i32 @foo2() to label %bb0 unwind label %bb1
+; CHECK: ^[[bb2]]:
+nocall:
+  ; CHECK: llvm.br ^[[bb4:.*]](%[[c0]], %[[c1]], %[[c2]] : i32, i32, i32)
+  br label %bb0
+; CHECK: ^[[bb3]]:
+  ; CHECK: llvm.br ^[[bb4]](%[[invoke]], %[[c20]], %[[invoke]] : i32, i32, i32)
+; CHECK: ^[[bb4]](%[[barg0:.*]]: i32, %[[barg1:.*]]: i32, %[[barg2:.*]]: i32):
+bb0:
+  %a = phi i32 [ 0, %nocall ], [ %invoke, %call ]
+  %b = phi i32 [ 1, %nocall ], [ 20, %call ]
+  %c = phi i32 [ 2, %nocall ], [ %invoke, %call ]
+  ; CHECK: %[[add0:.*]] = llvm.add %[[barg0]], %[[barg1]] : i32
+  ; CHECK: %[[add1:.*]] = llvm.add %[[barg2]], %[[add0]] : i32
+  %d = add i32 %a, %b
+  %e = add i32 %c, %d
+  ; CHECK: llvm.return %[[add1]] : i32
+  ret i32 %e
+; CHECK: ^[[bb5]]:
+bb1:
+  ; CHECK: %[[lp:.*]] = llvm.landingpad cleanup : i32
+  %resume = landingpad i32 cleanup
+  ; CHECK: llvm.resume %[[lp]] : i32
+  resume i32 %resume
+}


        


More information about the Mlir-commits mailing list