-
Notifications
You must be signed in to change notification settings - Fork 146
[CIR][Lowering] Core dialects: passthrough symbol visibility #1620
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
base: main
Are you sure you want to change the base?
Conversation
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.
Awesome, thanks for your first contributions. Can you please a testcase?
…to created func.func in cirtomlir lowering
… when convertion MLIR core module to LLVM MLIR module + added removal of unnecessary CIR Attr
adee41c
to
280bb46
Compare
Hey, I’ve added two test cases that are very similar to the examples I mentioned in the issue description. As expected, the tests failed without the changes and passed with them. This is my first time writing tests with lit/FileCheck, so if you notice anything that could be improved, I’d appreciate your feedback — but they might already be fine as they are. I was also unsure about the naming, so if you have better suggestions, feel free to let me know. |
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.
No problemo, here to help. Thanks for adding the tests - some nits but LGTM once fixed.
…onstraint to compilation test to fix execution on windows and mac
Thanks for the feedback! I've implemented the requested changes. Additionally, I added the -triple x86_64-unknown-linux-gnu option to the %clang_cc1 invocation in the declaration.c test, following the pattern used in other ThroughMLIR tests. I also constrained the compilation test to run only on x86_64 Linux targets, so hopefully both will now pass on Windows and macOS as well. I wasn't entirely sure which other targets to include. Based on CIRGenModule::getTargetCIRGenInfo(), it might make sense to relax the constraints in the future to support certain aarch64 targets (and possibly spirv64, nvptx, and amdgcn). But for now, I’ve conservatively limited the test to x86_64 Linux only. |
@@ -25,6 +25,7 @@ | |||
// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR_MACOS | |||
// RUN: %clang -target arm64-apple-macosx12.0.0 -fclangir -S -emit-llvm %s -o %t3.ll | |||
// RUN: FileCheck --input-file=%t3.ll %s -check-prefix=LLVM_MACOS | |||
// RUN: %clang -target x86_64-unknown-linux-gnu -fclangir -fno-clangir-direct-lowering -c %s -o %t |
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.
This path is already tested up there in the other -fno-clangir-direct-lowering invocation, turns out you don't need this test.
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.
Maybe I'm missing something here but I don't see where this is already tested. I't looks to me like all the other tests using the indirect lowering "only" create the cir,core dialects or llvm ir and never actually compile to an object file (the error occurs when trying to compile the llvm ir to an object file since during the mlir core to llvm ir translation the cir.triple attribute is not converted to the llvm.triple attribute and is thus discarded). If I try to add this line to the driver.c test and run the test locally (on ubuntu) with the current code on llvm/clangir:main I get the error mentioned in issue #1619
error: unable to create target: 'No available targets are compatible with triple ""'
If I run the test locally with the update code of this PR the test passes, so it seems to me like it does add value.
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.
True, thanks for clarifying! One last change, use -o %t.o
(and btw @bcardosolopes thanks for all the help and info on this PR and sorry about missing your suggestion about the space identation earlier) |
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.
Thanks for your patience, one last round of nits and LGTM!
int declaration(int x); | ||
int declaration_test() { | ||
return declaration(15); | ||
} |
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.
One more nit: code style requires all files to terminate with a newline,
@@ -25,6 +25,7 @@ | |||
// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR_MACOS | |||
// RUN: %clang -target arm64-apple-macosx12.0.0 -fclangir -S -emit-llvm %s -o %t3.ll | |||
// RUN: FileCheck --input-file=%t3.ll %s -check-prefix=LLVM_MACOS | |||
// RUN: %clang -target x86_64-unknown-linux-gnu -fclangir -fno-clangir-direct-lowering -c %s -o %t |
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.
True, thanks for clarifying! One last change, use -o %t.o
Fixes #1619
Fixes #1618