Skip to content

[mlir][EmitC] Remove unreachable code and fix Windows build warning #80677

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
Feb 6, 2024

Conversation

simon-camp
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Feb 5, 2024

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-emitc

Author: Simon Camphausen (simon-camp)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/80677.diff

1 Files Affected:

  • (modified) mlir/lib/Target/Cpp/TranslateToCpp.cpp (+7-2)
diff --git a/mlir/lib/Target/Cpp/TranslateToCpp.cpp b/mlir/lib/Target/Cpp/TranslateToCpp.cpp
index c0c6105409f8d8..194c79ff30cba2 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 {

@simon-camp simon-camp force-pushed the emitc.emitter.fix branch 2 times, most recently from aa77e80 to 4c326d8 Compare February 5, 2024 15:35
Copy link
Member

@marbre marbre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

@aniragil
Copy link
Contributor

aniragil commented Feb 6, 2024

LGTM! 👍

+1 👍

@simon-camp simon-camp merged commit 8924a9f into llvm:main Feb 6, 2024
@simon-camp simon-camp deleted the emitc.emitter.fix branch February 6, 2024 11:04
mgehre-amd pushed a commit to Xilinx/llvm-project that referenced this pull request Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants