Expose AddModuleFlag functionality within LLVMModuleRef#181
Merged
tannergooding merged 12 commits intodotnet:mainfrom Nov 15, 2021
Merged
Expose AddModuleFlag functionality within LLVMModuleRef#181tannergooding merged 12 commits intodotnet:mainfrom
tannergooding merged 12 commits intodotnet:mainfrom
Conversation
added 5 commits
November 11, 2021 12:31
ryan-moreno
commented
Nov 12, 2021
|
|
||
| public static bool LinkModules(LLVMModuleRef Dest, LLVMModuleRef Src) | ||
| { | ||
| return Convert.ToBoolean(LLVM.LinkModules2(Dest, Src)); |
Member
There was a problem hiding this comment.
The following is simpler and going to be much more efficient:
Suggested change
| return Convert.ToBoolean(LLVM.LinkModules2(Dest, Src)); | |
| return LLVM.LinkModules2(Dest, Src) != 0; |
Contributor
Author
There was a problem hiding this comment.
Updated with your suggestion. Since this is effectively just a wrapper around LLVM.LinkModules2 (no longer a function for the LLVMModuleRef class), I think it might be better off without this function entirely. Thoughts?
Member
There was a problem hiding this comment.
Either works. There isn't some "C wrapper" for the LLVM Linker type exposed by C++; so there isn't a separate "better" place to expose a friendly wrapper.
Co-authored-by: Tanner Gooding <tagoo@outlook.com>
tannergooding
approved these changes
Nov 15, 2021
Member
|
Thanks for the contribution! |
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
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 exposes the LLVMAddModuleFlag and LLVMLinkModules2 functionality within the LLVMModuleRef class. This allows for a more straightforward method for adding module flags using the LLVMSharp API and provides a way to link modules using the LLVMSharp API. It also adds a test to ensure that LLVMAddModuleFlag constructs the correct flag behavior in the outputted debug information.
The addition of the AddModuleFlag functionality also helps to clarify this situation:
There are two different ways to add a module flag in LLVM Native: A) using LLVMAddModuleFlag (which expects a 0-based LLVMModuleFlagBehavior) and B) using LLVMAddNamedMetadataOperand (which expects a 1-based behavior represented by a uint). Exposing the AddModuleFlag functionality is meant to ease this confusion by adding a more straightforward method to create module flags that uses the LLVMModuleFlagBehavior enum as expected.