-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[CIR] Upstream enum support #136807
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
[CIR] Upstream enum support #136807
Conversation
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clangir Author: Ankur Ahir (Ankur-0429) Changes#136055 This PR adds basic support for enum declarations in CIR by handling the Decl::Enum case in CIRGenModule::emitTopLevelDecl(). The implementation currently asserts when debug info generation is requested. A simple test case with an anonymous enum declaration has been added to verify the functionality. Full diff: https://github.com/llvm/llvm-project/pull/136807.diff 3 Files Affected:
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3b13d495be5e3..79db25dda3fea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -617,6 +617,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
case Decl::OpenACCDeclare:
emitGlobalOpenACCDecl(cast<OpenACCDeclareDecl>(decl));
break;
+ case Decl::Enum:
+ assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+ break;
case Decl::Typedef:
case Decl::TypeAlias: // using foo = bar; [C++11]
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
// OGCG: define{{.*}} i64 @max_size()
// OGCG: ret i64 2305843009213693951
+
+enum {
+ um = 0,
+ dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 0f8431325a86f..c1c3e60079869 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -102,3 +102,8 @@ size_type max_size() {
// CHECK: %3 = cir.cast(integral, %2 : !s32i), !u64i
// CHECK: %4 = cir.const #cir.int<8> : !u64i
// CHECK: %5 = cir.binop(div, %3, %4) : !u64i
+
+enum {
+ um = 0,
+ dois = 1,
+};
\ No newline at end of file
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Title should start with [CIR] ...
, more comments inline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also want to see tests that show uses of an enum, as well as fixed underlying type, scoped enums/etc.
Going to wait to confirm I did the "fixed underlying type" part first. If you have more specific enum use cases that we should test for, please let me know. |
You have not. Something like:
Note the first two are valid in C, and I'd like to make sure we get them in various stages of 'completeness' during emitting. |
Hi @Ankur-0429, I just noticed that you merged your changes instead of rebasing them. According to the LLVM GitHub workflow documentation, you should rebase your branch onto Merge commits are not allowed. The main branch is configured to reject pushes that include merges. You can read more about this here: Since the changes were merged, your commit now shows a large diff ( |
FWIW, if one is using the gh interface, commits are usually squashed before they get merged, so in practice this isn't a problem - I never seen any actual problems. Not sure if docs are making a different assumption about landing tho |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just two nits and previous comments from other reviewers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
a26c8e6
to
2f055ec
Compare
what I get for trying to rebase 🙃 . I'll probably just make another pull request with the relevent changes. |
Rebase locally and force push. Creating a new PR lose the context and is a less ideal option. |
f418fb1
to
b911caf
Compare
fc5f5a6
to
8f5e511
Compare
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/169/builds/11316 Here is the relevant piece of the build log for the reference
|
#136055
This PR adds basic support for enum declarations in CIR by handling the Decl::Enum case in CIRGenModule::emitTopLevelDecl(). The implementation currently asserts when debug info generation is requested.
A simple test case with an anonymous enum declaration has been added to verify the functionality.