-
Notifications
You must be signed in to change notification settings - Fork 162
[CIR][CIRGen] Add comdat support, enabling more dso_local and comdat LLVM tagging #751
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bcardosolopes
requested changes
Jul 24, 2024
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.
Nice, thanks! One more comment
The PR title also needs a space |
bcardosolopes
approved these changes
Jul 25, 2024
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 few minor needed changes!
ghehg
commented
Jul 26, 2024
Hugobros3
pushed a commit
to shady-gang/clangir
that referenced
this pull request
Oct 2, 2024
…LLVM tagging (llvm#751) This PR implements: 1. Add comdat attribute as an optional attribute to CIR GlobalOp and FuncOp, they are of the enum ComdatSelection type because it contains all information we need. The [llvm/include/llvm/IR/Comdat.h](https://github.com/llvm/clangir/blob/4ea2ec38638391b964e88b77f926e0892b350e04/llvm/include/llvm/IR/Comdat.h#L33) has Comdat with selectionKind and its name, add users which are set of pointers to GlobalObjects sharing the same name. The name is always the name of global object (in CIR context, the GlobalOp or FuncOp), so we don't need it. And the user set can always be collected when a transformation looks up symbol table of the module, thus not really necessary. Plus, it's not good for CIR to keep a set of pointers. 2. Thanks to comdat support, and adding call sites of setComdat similar to what was in OG, we are able to implement canBenefitFromLocalAlias as similar as possible to [GlobalValue::canBenefitFromLocalAlias() ](https://github.com/llvm/clangir/blob/4ea2ec38638391b964e88b77f926e0892b350e04/llvm/lib/IR/Globals.cpp#L112) and this enable us to complete dso_local work by correctly setting dso_local for functions. 3. I took back printing of dsolocal attribute of CIR, as I would fix 128+ test cases instead of 36-37 of tests (mostly adding dso_local to function prototype line in LLVM check) in this PR. printing dsolocal attribute is not really necessary as llvm IR would verify it for us. 4. LLVM lowering of Comdat for GlobalOp Things left to next/future PR 1. I'd like to extend setComdat to other parts of CG like Vtable, etc. 2. LLVM lowering of comdat for FuncOp
smeenai
pushed a commit
to smeenai/clangir
that referenced
this pull request
Oct 9, 2024
…LLVM tagging (llvm#751) This PR implements: 1. Add comdat attribute as an optional attribute to CIR GlobalOp and FuncOp, they are of the enum ComdatSelection type because it contains all information we need. The [llvm/include/llvm/IR/Comdat.h](https://github.com/llvm/clangir/blob/4ea2ec38638391b964e88b77f926e0892b350e04/llvm/include/llvm/IR/Comdat.h#L33) has Comdat with selectionKind and its name, add users which are set of pointers to GlobalObjects sharing the same name. The name is always the name of global object (in CIR context, the GlobalOp or FuncOp), so we don't need it. And the user set can always be collected when a transformation looks up symbol table of the module, thus not really necessary. Plus, it's not good for CIR to keep a set of pointers. 2. Thanks to comdat support, and adding call sites of setComdat similar to what was in OG, we are able to implement canBenefitFromLocalAlias as similar as possible to [GlobalValue::canBenefitFromLocalAlias() ](https://github.com/llvm/clangir/blob/4ea2ec38638391b964e88b77f926e0892b350e04/llvm/lib/IR/Globals.cpp#L112) and this enable us to complete dso_local work by correctly setting dso_local for functions. 3. I took back printing of dsolocal attribute of CIR, as I would fix 128+ test cases instead of 36-37 of tests (mostly adding dso_local to function prototype line in LLVM check) in this PR. printing dsolocal attribute is not really necessary as llvm IR would verify it for us. 4. LLVM lowering of Comdat for GlobalOp Things left to next/future PR 1. I'd like to extend setComdat to other parts of CG like Vtable, etc. 2. LLVM lowering of comdat for FuncOp
smeenai
pushed a commit
to smeenai/clangir
that referenced
this pull request
Oct 9, 2024
…LLVM tagging (llvm#751) This PR implements: 1. Add comdat attribute as an optional attribute to CIR GlobalOp and FuncOp, they are of the enum ComdatSelection type because it contains all information we need. The [llvm/include/llvm/IR/Comdat.h](https://github.com/llvm/clangir/blob/4ea2ec38638391b964e88b77f926e0892b350e04/llvm/include/llvm/IR/Comdat.h#L33) has Comdat with selectionKind and its name, add users which are set of pointers to GlobalObjects sharing the same name. The name is always the name of global object (in CIR context, the GlobalOp or FuncOp), so we don't need it. And the user set can always be collected when a transformation looks up symbol table of the module, thus not really necessary. Plus, it's not good for CIR to keep a set of pointers. 2. Thanks to comdat support, and adding call sites of setComdat similar to what was in OG, we are able to implement canBenefitFromLocalAlias as similar as possible to [GlobalValue::canBenefitFromLocalAlias() ](https://github.com/llvm/clangir/blob/4ea2ec38638391b964e88b77f926e0892b350e04/llvm/lib/IR/Globals.cpp#L112) and this enable us to complete dso_local work by correctly setting dso_local for functions. 3. I took back printing of dsolocal attribute of CIR, as I would fix 128+ test cases instead of 36-37 of tests (mostly adding dso_local to function prototype line in LLVM check) in this PR. printing dsolocal attribute is not really necessary as llvm IR would verify it for us. 4. LLVM lowering of Comdat for GlobalOp Things left to next/future PR 1. I'd like to extend setComdat to other parts of CG like Vtable, etc. 2. LLVM lowering of comdat for FuncOp
keryell
pushed a commit
to keryell/clangir
that referenced
this pull request
Oct 19, 2024
…LLVM tagging (llvm#751) This PR implements: 1. Add comdat attribute as an optional attribute to CIR GlobalOp and FuncOp, they are of the enum ComdatSelection type because it contains all information we need. The [llvm/include/llvm/IR/Comdat.h](https://github.com/llvm/clangir/blob/4ea2ec38638391b964e88b77f926e0892b350e04/llvm/include/llvm/IR/Comdat.h#L33) has Comdat with selectionKind and its name, add users which are set of pointers to GlobalObjects sharing the same name. The name is always the name of global object (in CIR context, the GlobalOp or FuncOp), so we don't need it. And the user set can always be collected when a transformation looks up symbol table of the module, thus not really necessary. Plus, it's not good for CIR to keep a set of pointers. 2. Thanks to comdat support, and adding call sites of setComdat similar to what was in OG, we are able to implement canBenefitFromLocalAlias as similar as possible to [GlobalValue::canBenefitFromLocalAlias() ](https://github.com/llvm/clangir/blob/4ea2ec38638391b964e88b77f926e0892b350e04/llvm/lib/IR/Globals.cpp#L112) and this enable us to complete dso_local work by correctly setting dso_local for functions. 3. I took back printing of dsolocal attribute of CIR, as I would fix 128+ test cases instead of 36-37 of tests (mostly adding dso_local to function prototype line in LLVM check) in this PR. printing dsolocal attribute is not really necessary as llvm IR would verify it for us. 4. LLVM lowering of Comdat for GlobalOp Things left to next/future PR 1. I'd like to extend setComdat to other parts of CG like Vtable, etc. 2. LLVM lowering of comdat for FuncOp
lanza
pushed a commit
that referenced
this pull request
Nov 5, 2024
…LLVM tagging (#751) This PR implements: 1. Add comdat attribute as an optional attribute to CIR GlobalOp and FuncOp, they are of the enum ComdatSelection type because it contains all information we need. The [llvm/include/llvm/IR/Comdat.h](https://github.com/llvm/clangir/blob/4ea2ec38638391b964e88b77f926e0892b350e04/llvm/include/llvm/IR/Comdat.h#L33) has Comdat with selectionKind and its name, add users which are set of pointers to GlobalObjects sharing the same name. The name is always the name of global object (in CIR context, the GlobalOp or FuncOp), so we don't need it. And the user set can always be collected when a transformation looks up symbol table of the module, thus not really necessary. Plus, it's not good for CIR to keep a set of pointers. 2. Thanks to comdat support, and adding call sites of setComdat similar to what was in OG, we are able to implement canBenefitFromLocalAlias as similar as possible to [GlobalValue::canBenefitFromLocalAlias() ](https://github.com/llvm/clangir/blob/4ea2ec38638391b964e88b77f926e0892b350e04/llvm/lib/IR/Globals.cpp#L112) and this enable us to complete dso_local work by correctly setting dso_local for functions. 3. I took back printing of dsolocal attribute of CIR, as I would fix 128+ test cases instead of 36-37 of tests (mostly adding dso_local to function prototype line in LLVM check) in this PR. printing dsolocal attribute is not really necessary as llvm IR would verify it for us. 4. LLVM lowering of Comdat for GlobalOp Things left to next/future PR 1. I'd like to extend setComdat to other parts of CG like Vtable, etc. 2. LLVM lowering of comdat for FuncOp
lanza
pushed a commit
that referenced
this pull request
Mar 18, 2025
…LLVM tagging (#751) This PR implements: 1. Add comdat attribute as an optional attribute to CIR GlobalOp and FuncOp, they are of the enum ComdatSelection type because it contains all information we need. The [llvm/include/llvm/IR/Comdat.h](https://github.com/llvm/clangir/blob/4ea2ec38638391b964e88b77f926e0892b350e04/llvm/include/llvm/IR/Comdat.h#L33) has Comdat with selectionKind and its name, add users which are set of pointers to GlobalObjects sharing the same name. The name is always the name of global object (in CIR context, the GlobalOp or FuncOp), so we don't need it. And the user set can always be collected when a transformation looks up symbol table of the module, thus not really necessary. Plus, it's not good for CIR to keep a set of pointers. 2. Thanks to comdat support, and adding call sites of setComdat similar to what was in OG, we are able to implement canBenefitFromLocalAlias as similar as possible to [GlobalValue::canBenefitFromLocalAlias() ](https://github.com/llvm/clangir/blob/4ea2ec38638391b964e88b77f926e0892b350e04/llvm/lib/IR/Globals.cpp#L112) and this enable us to complete dso_local work by correctly setting dso_local for functions. 3. I took back printing of dsolocal attribute of CIR, as I would fix 128+ test cases instead of 36-37 of tests (mostly adding dso_local to function prototype line in LLVM check) in this PR. printing dsolocal attribute is not really necessary as llvm IR would verify it for us. 4. LLVM lowering of Comdat for GlobalOp Things left to next/future PR 1. I'd like to extend setComdat to other parts of CG like Vtable, etc. 2. LLVM lowering of comdat for FuncOp
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements:
and this enable us to complete dso_local work by correctly setting dso_local for functions.
Things left to next/future PR