[Mlir-commits] [mlir] [mlir][EmitC] Remove unreachable code and fix Windows build warning (PR #80677)

Simon Camphausen llvmlistbot at llvm.org
Mon Feb 5 05:06:31 PST 2024


https://github.com/simon-camp created https://github.com/llvm/llvm-project/pull/80677

None

>From b0033f66af23a4571bf609959aa38de4eeda34f7 Mon Sep 17 00:00:00 2001
From: Simon Camphausen <simon.camphausen at iml.fraunhofer.de>
Date: Mon, 5 Feb 2024 13:01:09 +0000
Subject: [PATCH] [mlir][EmitC] Remove unreachable code and fix Windows build
 warning

---
 mlir/lib/Target/Cpp/TranslateToCpp.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/mlir/lib/Target/Cpp/TranslateToCpp.cpp b/mlir/lib/Target/Cpp/TranslateToCpp.cpp
index c0c6105409f8d..194c79ff30cba 100644
--- a/mlir/lib/Target/Cpp/TranslateToCpp.cpp
+++ b/mlir/lib/Target/Cpp/TranslateToCpp.cpp
@@ -86,13 +86,18 @@ static int getOperatorPrecedence(Operation *operation) {
         case emitc::CmpPredicate::three_way:
           return 10;
         }
+        llvm_unreachable("Unsupported cmp predicate");
+        return 1;
       })
       .Case<emitc::DivOp>([&](auto op) { return 12; })
       .Case<emitc::MulOp>([&](auto op) { return 12; })
       .Case<emitc::RemOp>([&](auto op) { return 12; })
       .Case<emitc::SubOp>([&](auto op) { return 11; })
-      .Case<emitc::CallOpaqueOp>([&](auto op) { return 14; });
-  llvm_unreachable("Unsupported operator");
+      .Case<emitc::CallOpaqueOp>([&](auto op) { return 14; })
+      .Default([](auto op) {
+        llvm_unreachable("Unsupported operator");
+        return 1;
+      });
 }
 
 namespace {



More information about the Mlir-commits mailing list