Skip to content
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

Source code location of IR instruction #1070

Open
xuzhaoch opened this issue Jul 22, 2024 · 4 comments
Open

Source code location of IR instruction #1070

xuzhaoch opened this issue Jul 22, 2024 · 4 comments
Labels
feature_request Feature Request

Comments

@xuzhaoch
Copy link


Feature request

I am using IR files to construct data flow for some specific static code check.
llvmlite helps me to convert ir file to the data which I can use directly.
And I also noticed that at the end of the ir file, there are metadata for every instructions, which can offer the source code location.
Is there any function or interface in the llvmlite, that can give the source code location of every instruction?

@esc esc added the question label Jul 23, 2024
@esc
Copy link
Member

esc commented Jul 23, 2024

Unfortunately this isn't supported and you will have to parse the file manually.

@esc esc added feature_request Feature Request and removed question labels Jul 23, 2024
@xuzhaoch
Copy link
Author

Unfortunately this isn't supported and you will have to parse the file manually.

If using llvmlite.binding.parse_bitcode to parse the bc file, can I get these metadata lines?
Or the only way is to read the ll file and use regex to extract the corresponding content?

@esc
Copy link
Member

esc commented Aug 5, 2024

Unfortunately this isn't supported and you will have to parse the file manually.

If using llvmlite.binding.parse_bitcode to parse the bc file, can I get these metadata lines? Or the only way is to read the ll file and use regex to extract the corresponding content?

Looking at:

https://llvmlite.readthedocs.io/en/latest/user-guide/binding/modules.html#llvmlite.binding.parse_bitcode

my guess is that the data you are looking for will not be part of the returned ModuleRef. So yes, as far as I can tell, you'll need to use regular expressions.

@gmarkall
Copy link
Member

gmarkall commented Aug 7, 2024

My interpretation of this request is that we could support this by wrapping the getDebugLoc() function (and similar / related APIs as necessary).

I don't think there's availability for anyone to pick this up right now, but I think a contribution that implements support for the required APIs could be considered. However, to provide appropriate expectations: any PR that we could practically review would have to be fairly complete - i.e. include appropriate tests and documentation, and for the changes to be in keeping with the existing codebase - I don't think we have the bandwidth to guide / mentor the development of such a contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature_request Feature Request
Projects
None yet
Development

No branches or pull requests

3 participants