diff --git a/llvm/test/Transforms/Util/flattencfg.ll b/llvm/test/Transforms/Util/flattencfg.ll --- a/llvm/test/Transforms/Util/flattencfg.ll +++ b/llvm/test/Transforms/Util/flattencfg.ll @@ -1,11 +1,27 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2 ; RUN: opt -passes=flattencfg -S < %s | FileCheck %s ; This test checks whether the pass completes without a crash. ; The code is not transformed in any way -; -; CHECK-LABEL: @test_not_crash define void @test_not_crash(i32 %in_a) #0 { +; CHECK-LABEL: define void @test_not_crash +; CHECK-SAME: (i32 [[IN_A:%.*]]) { +; CHECK-NEXT: entry: +; CHECK-NEXT: [[CMP0:%.*]] = icmp eq i32 [[IN_A]], -1 +; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i32 [[IN_A]], 0 +; CHECK-NEXT: [[COND0:%.*]] = and i1 [[CMP0]], [[CMP1]] +; CHECK-NEXT: br i1 [[COND0]], label [[B0:%.*]], label [[B1:%.*]] +; CHECK: b0: +; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i32 [[IN_A]], 0 +; CHECK-NEXT: [[CMP3:%.*]] = icmp ne i32 [[IN_A]], 1 +; CHECK-NEXT: [[COND1:%.*]] = or i1 [[CMP2]], [[CMP3]] +; CHECK-NEXT: br i1 [[COND1]], label [[EXIT:%.*]], label [[B1]] +; CHECK: b1: +; CHECK-NEXT: br label [[EXIT]] +; CHECK: exit: +; CHECK-NEXT: ret void +; entry: %cmp0 = icmp eq i32 %in_a, -1 %cmp1 = icmp ne i32 %in_a, 0 @@ -25,17 +41,19 @@ ret void } -; CHECK-LABEL: @test_not_crash2 +define void @test_not_crash2(float %a, float %b) #0 { +; CHECK-LABEL: define void @test_not_crash2 +; CHECK-SAME: (float [[A:%.*]], float [[B:%.*]]) { ; CHECK-NEXT: entry: -; CHECK-NEXT: %0 = fcmp ult float %a -; CHECK-NEXT: %1 = fcmp ult float %b -; CHECK-NEXT: [[COND:%[a-z0-9]+]] = and i1 %0, %1 -; CHECK-NEXT: br i1 [[COND]], label %bb4, label %bb3 +; CHECK-NEXT: [[TMP0:%.*]] = fcmp ult float [[A]], 1.000000e+00 +; CHECK-NEXT: [[TMP1:%.*]] = fcmp ult float [[B]], 1.000000e+00 +; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP0]], [[TMP1]] +; CHECK-NEXT: br i1 [[TMP2]], label [[BB4:%.*]], label [[BB3:%.*]] ; CHECK: bb3: -; CHECK-NEXT: br label %bb4 +; CHECK-NEXT: br label [[BB4]] ; CHECK: bb4: ; CHECK-NEXT: ret void -define void @test_not_crash2(float %a, float %b) #0 { +; entry: %0 = fcmp ult float %a, 1.000000e+00 br i1 %0, label %bb0, label %bb1 @@ -54,18 +72,20 @@ br i1 %1, label %bb4, label %bb3 } -; CHECK-LABEL: @test_not_crash3 +define void @test_not_crash3(i32 %a) #0 { +; CHECK-LABEL: define void @test_not_crash3 +; CHECK-SAME: (i32 [[A:%.*]]) { ; CHECK-NEXT: entry: -; CHECK-NEXT: %a_eq_0 = icmp eq i32 %a, 0 -; CHECK-NEXT: %a_eq_1 = icmp eq i32 %a, 1 -; CHECK-NEXT: [[COND:%[a-z0-9]+]] = or i1 %a_eq_0, %a_eq_1 -; CHECK-NEXT: br i1 [[COND]], label %bb2, label %bb3 +; CHECK-NEXT: [[A_EQ_0:%.*]] = icmp eq i32 [[A]], 0 +; CHECK-NEXT: [[A_EQ_1:%.*]] = icmp eq i32 [[A]], 1 +; CHECK-NEXT: [[TMP0:%.*]] = or i1 [[A_EQ_0]], [[A_EQ_1]] +; CHECK-NEXT: br i1 [[TMP0]], label [[BB2:%.*]], label [[BB3:%.*]] ; CHECK: bb2: -; CHECK-NEXT: br label %bb3 +; CHECK-NEXT: br label [[BB3]] ; CHECK: bb3: -; CHECK-NEXT: %check_badref = phi i32 [ 17, %entry ], [ 11, %bb2 ] +; CHECK-NEXT: [[CHECK_BADREF:%.*]] = phi i32 [ 17, [[ENTRY:%.*]] ], [ 11, [[BB2]] ] ; CHECK-NEXT: ret void -define void @test_not_crash3(i32 %a) #0 { +; entry: %a_eq_0 = icmp eq i32 %a, 0 br i1 %a_eq_0, label %bb0, label %bb1 @@ -88,18 +108,20 @@ @g = global i32 0, align 4 -; CHECK-LABEL: @test_then +define void @test_then(i32 %x, i32 %y, i32 %z) { +; CHECK-LABEL: define void @test_then +; CHECK-SAME: (i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) { ; CHECK-NEXT: entry.x: -; CHECK-NEXT: %cmp.x = icmp ne i32 %x, 0 -; CHECK-NEXT: %cmp.y = icmp ne i32 %y, 0 -; CHECK-NEXT: [[COND:%[a-z0-9]+]] = or i1 %cmp.x, %cmp.y -; CHECK-NEXT: br i1 [[COND]], label %if.then.y, label %exit +; CHECK-NEXT: [[CMP_X:%.*]] = icmp ne i32 [[X]], 0 +; CHECK-NEXT: [[CMP_Y:%.*]] = icmp ne i32 [[Y]], 0 +; CHECK-NEXT: [[TMP0:%.*]] = or i1 [[CMP_X]], [[CMP_Y]] +; CHECK-NEXT: br i1 [[TMP0]], label [[IF_THEN_Y:%.*]], label [[EXIT:%.*]] ; CHECK: if.then.y: -; CHECK-NEXT: store i32 %z, ptr @g, align 4 -; CHECK-NEXT: br label %exit +; CHECK-NEXT: store i32 [[Z]], ptr @g, align 4 +; CHECK-NEXT: br label [[EXIT]] ; CHECK: exit: ; CHECK-NEXT: ret void -define void @test_then(i32 %x, i32 %y, i32 %z) { +; entry.x: %cmp.x = icmp ne i32 %x, 0 br i1 %cmp.x, label %if.then.x, label %entry.y @@ -120,18 +142,20 @@ ret void } -; CHECK-LABEL: @test_else +define void @test_else(i32 %x, i32 %y, i32 %z) { +; CHECK-LABEL: define void @test_else +; CHECK-SAME: (i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) { ; CHECK-NEXT: entry.x: -; CHECK-NEXT: %cmp.x = icmp eq i32 %x, 0 -; CHECK-NEXT: %cmp.y = icmp eq i32 %y, 0 -; CHECK-NEXT: [[COND:%[a-z0-9]+]] = and i1 %cmp.x, %cmp.y -; CHECK-NEXT: br i1 [[COND]], label %exit, label %if.else.y +; CHECK-NEXT: [[CMP_X:%.*]] = icmp eq i32 [[X]], 0 +; CHECK-NEXT: [[CMP_Y:%.*]] = icmp eq i32 [[Y]], 0 +; CHECK-NEXT: [[TMP0:%.*]] = and i1 [[CMP_X]], [[CMP_Y]] +; CHECK-NEXT: br i1 [[TMP0]], label [[EXIT:%.*]], label [[IF_ELSE_Y:%.*]] ; CHECK: if.else.y: -; CHECK-NEXT: store i32 %z, ptr @g, align 4 -; CHECK-NEXT: br label %exit +; CHECK-NEXT: store i32 [[Z]], ptr @g, align 4 +; CHECK-NEXT: br label [[EXIT]] ; CHECK: exit: ; CHECK-NEXT: ret void -define void @test_else(i32 %x, i32 %y, i32 %z) { +; entry.x: %cmp.x = icmp eq i32 %x, 0 br i1 %cmp.x, label %entry.y, label %if.else.x @@ -152,18 +176,20 @@ ret void } -; CHECK-LABEL: @test_combine_and +define void @test_combine_and(i32 %x, i32 %y, i32 %z) { +; CHECK-LABEL: define void @test_combine_and +; CHECK-SAME: (i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) { ; CHECK-NEXT: entry.x: -; CHECK-NEXT: %cmp.x = icmp eq i32 %x, 0 -; CHECK-NEXT: %cmp.y = icmp eq i32 %y, 0 -; CHECK-NEXT: [[COND:%[a-z0-9]+]] = and i1 %cmp.x, %cmp.y -; CHECK-NEXT: br i1 [[COND]], label %exit, label %if.then.y +; CHECK-NEXT: [[CMP_X:%.*]] = icmp eq i32 [[X]], 0 +; CHECK-NEXT: [[CMP_Y:%.*]] = icmp eq i32 [[Y]], 0 +; CHECK-NEXT: [[TMP0:%.*]] = and i1 [[CMP_X]], [[CMP_Y]] +; CHECK-NEXT: br i1 [[TMP0]], label [[EXIT:%.*]], label [[IF_THEN_Y:%.*]] ; CHECK: if.then.y: -; CHECK-NEXT: store i32 %z, ptr @g, align 4 -; CHECK-NEXT: br label %exit +; CHECK-NEXT: store i32 [[Z]], ptr @g, align 4 +; CHECK-NEXT: br label [[EXIT]] ; CHECK: exit: ; CHECK-NEXT: ret void -define void @test_combine_and(i32 %x, i32 %y, i32 %z) { +; entry.x: %cmp.x = icmp eq i32 %x, 0 br i1 %cmp.x, label %entry.y, label %if.else.x @@ -184,18 +210,20 @@ ret void } -; CHECK-LABEL: @test_combine_or +define void @test_combine_or(i32 %x, i32 %y, i32 %z) { +; CHECK-LABEL: define void @test_combine_or +; CHECK-SAME: (i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) { ; CHECK-NEXT: entry.x: -; CHECK-NEXT: %cmp.x = icmp ne i32 %x, 0 -; CHECK-NEXT: %cmp.y = icmp ne i32 %y, 0 -; CHECK-NEXT: [[COND:%[a-z0-9]+]] = or i1 %cmp.x, %cmp.y -; CHECK-NEXT: br i1 [[COND]], label %if.else.y, label %exit +; CHECK-NEXT: [[CMP_X:%.*]] = icmp ne i32 [[X]], 0 +; CHECK-NEXT: [[CMP_Y:%.*]] = icmp ne i32 [[Y]], 0 +; CHECK-NEXT: [[TMP0:%.*]] = or i1 [[CMP_X]], [[CMP_Y]] +; CHECK-NEXT: br i1 [[TMP0]], label [[IF_ELSE_Y:%.*]], label [[EXIT:%.*]] ; CHECK: if.else.y: -; CHECK-NEXT: store i32 %z, ptr @g, align 4 -; CHECK-NEXT: br label %exit +; CHECK-NEXT: store i32 [[Z]], ptr @g, align 4 +; CHECK-NEXT: br label [[EXIT]] ; CHECK: exit: ; CHECK-NEXT: ret void -define void @test_combine_or(i32 %x, i32 %y, i32 %z) { +; entry.x: %cmp.x = icmp ne i32 %x, 0 br i1 %cmp.x, label %if.then.x, label %entry.y @@ -216,12 +244,19 @@ ret void } -; This would crash. - declare i1 @llvm.smax.i1(i1, i1) #0 -; CHECK-LABEL: @PR56875 define void @PR56875(i1 %val_i1_5) { +; CHECK-LABEL: define void @PR56875 +; CHECK-SAME: (i1 [[VAL_I1_5:%.*]]) { +; CHECK-NEXT: entry_1: +; CHECK-NEXT: ret void +; CHECK: bb_2: +; CHECK-NEXT: br label [[BB_4:%.*]] +; CHECK: bb_4: +; CHECK-NEXT: [[VAL_I1_46:%.*]] = call i1 @llvm.smax.i1(i1 [[VAL_I1_5]], i1 [[VAL_I1_5]]) +; CHECK-NEXT: br i1 [[VAL_I1_46]], label [[BB_4]], label [[BB_2:%.*]] +; entry_1: ret void diff --git a/mlir/utils/emacs/mlir-mode.el b/mlir/utils/emacs/mlir-mode.el --- a/mlir/utils/emacs/mlir-mode.el +++ b/mlir/utils/emacs/mlir-mode.el @@ -74,6 +74,11 @@ ;;;###autoload (add-to-list 'auto-mode-alist (cons "\\.mlir\\'" 'mlir-mode)) +(defgroup mlir nil + "Major mode for editing MLIR source files." + :group 'languages + :prefix "mlir-") + ;; Set default value of opt-tool to use as mlir-opt. (defcustom mlir-opt "mlir-opt" "Commandline MLIR opt tool to use."