-
Notifications
You must be signed in to change notification settings - Fork 115
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][Lowering] Emit llvm.global_ctors list #240
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.
This is great, thanks!
Out of curiosity, have you considered an alternative approach where instead of annotating the functions, we instead create an attribute that holds the list of symbols+prio of said global constructors? With that you only need to look at one attribute in buildCtorList
instead of walking every function.
Since I might be missing some context: is adding that as a function attribute unlocks any type of analysis you're thinking about in the future?
I don't have a strong preference, just putting the compile-time hat for this one.
I don't have a strong preference either. An attribute listing all global constructors is probably better for compile time. I guess that would be a module attribute and we need to print it, otherwise the serialized IR isn't self-contained. |
That works for me too, it can probably be a bit more adhoc for now, given we don't have a |
On the second thought, would the printing be too lengthy if there are many globalops? |
It's possible, but isn't that the case for any long thing in LLVM already? |
I mean if we print the attribute in the module header, as we do today, it may look a bit weird for a long list. LLVM IR prints attributes in the end. |
For real TUs I don't see much problem cause they are noisy/full-of-content regardless, for testcases it's only going to show up whenever we have global initializers w/ ctors. All that to say that I don't think it bothers me (versus paying for compile time). |
e6eaacf
to
0c2f374
Compare
0c2f374
to
ee1409b
Compare
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.
Sweet, almost there, see inline comments.
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 with minor changes!
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags:
2d6f7c3
to
00b2a9c
Compare
Creating the `llvm.global_ctors` list to hold all global dynamic initializers. The list has the following format: ``` %0 = type { i32, ptr, ptr } @llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, ptr @ctor, ptr @DaTa }] ``` The list will be converted to `.init_array` for ELF by LLVM which will be loaded and executed by the C++ runtime.
Creating the `llvm.global_ctors` list to hold all global dynamic initializers. The list has the following format: ``` %0 = type { i32, ptr, ptr } @llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, ptr @ctor, ptr @DaTa }] ``` The list will be converted to `.init_array` for ELF by LLVM which will be loaded and executed by the C++ runtime.
Creating the `llvm.global_ctors` list to hold all global dynamic initializers. The list has the following format: ``` %0 = type { i32, ptr, ptr } @llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, ptr @ctor, ptr @DaTa }] ``` The list will be converted to `.init_array` for ELF by LLVM which will be loaded and executed by the C++ runtime.
Creating the `llvm.global_ctors` list to hold all global dynamic initializers. The list has the following format: ``` %0 = type { i32, ptr, ptr } @llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, ptr @ctor, ptr @DaTa }] ``` The list will be converted to `.init_array` for ELF by LLVM which will be loaded and executed by the C++ runtime.
Creating the `llvm.global_ctors` list to hold all global dynamic initializers. The list has the following format: ``` %0 = type { i32, ptr, ptr } @llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, ptr @ctor, ptr @DaTa }] ``` The list will be converted to `.init_array` for ELF by LLVM which will be loaded and executed by the C++ runtime.
Creating the `llvm.global_ctors` list to hold all global dynamic initializers. The list has the following format: ``` %0 = type { i32, ptr, ptr } @llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, ptr @ctor, ptr @DaTa }] ``` The list will be converted to `.init_array` for ELF by LLVM which will be loaded and executed by the C++ runtime.
Creating the `llvm.global_ctors` list to hold all global dynamic initializers. The list has the following format: ``` %0 = type { i32, ptr, ptr } @llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, ptr @ctor, ptr @DaTa }] ``` The list will be converted to `.init_array` for ELF by LLVM which will be loaded and executed by the C++ runtime.
Creating the `llvm.global_ctors` list to hold all global dynamic initializers. The list has the following format: ``` %0 = type { i32, ptr, ptr } @llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, ptr @ctor, ptr @DaTa }] ``` The list will be converted to `.init_array` for ELF by LLVM which will be loaded and executed by the C++ runtime.
Creating the `llvm.global_ctors` list to hold all global dynamic initializers. The list has the following format: ``` %0 = type { i32, ptr, ptr } @llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, ptr @ctor, ptr @DaTa }] ``` The list will be converted to `.init_array` for ELF by LLVM which will be loaded and executed by the C++ runtime.
Creating the `llvm.global_ctors` list to hold all global dynamic initializers. The list has the following format: ``` %0 = type { i32, ptr, ptr } @llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, ptr @ctor, ptr @DaTa }] ``` The list will be converted to `.init_array` for ELF by LLVM which will be loaded and executed by the C++ runtime.
Creating the `llvm.global_ctors` list to hold all global dynamic initializers. The list has the following format: ``` %0 = type { i32, ptr, ptr } @llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, ptr @ctor, ptr @DaTa }] ``` The list will be converted to `.init_array` for ELF by LLVM which will be loaded and executed by the C++ runtime.
Creating the `llvm.global_ctors` list to hold all global dynamic initializers. The list has the following format: ``` %0 = type { i32, ptr, ptr } @llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, ptr @ctor, ptr @DaTa }] ``` The list will be converted to `.init_array` for ELF by LLVM which will be loaded and executed by the C++ runtime.
Creating the `llvm.global_ctors` list to hold all global dynamic initializers. The list has the following format: ``` %0 = type { i32, ptr, ptr } @llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, ptr @ctor, ptr @DaTa }] ``` The list will be converted to `.init_array` for ELF by LLVM which will be loaded and executed by the C++ runtime.
Creating the `llvm.global_ctors` list to hold all global dynamic initializers. The list has the following format: ``` %0 = type { i32, ptr, ptr } @llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, ptr @ctor, ptr @DaTa }] ``` The list will be converted to `.init_array` for ELF by LLVM which will be loaded and executed by the C++ runtime.
Creating the
llvm.global_ctors
list to hold all global dynamic initializers. The list has the following format:The list will be converted to
.init_array
for ELF by LLVM which will be loaded and executed by the C++ runtime.