TheDan64 / inkwell

It's a New Kind of Wrapper for Exposing LLVM (Safely)
https://thedan64.github.io/inkwell/
Apache License 2.0
2.22k stars 217 forks source link

Provide get_gep_source_element_type and InstructionValue -> CallSiteValue #506

Open vaivaswatha opened 2 weeks ago

vaivaswatha commented 2 weeks ago

This PR adds two new functionality:

  1. get_gep_soruce_element_type: Takes as input a GEP instruction and returns the source element type.
  2. A try-conversion from InstructionValue to CallSite.

Related Issue

If the changes are acceptable (i.e., in the right direction), I'll create one and edit this description.

How This Has Been Tested

I've tested the change against LLVM-17, as "cargo test -F llvm17-0"

TheDan64 commented 2 weeks ago

@vaivaswatha there are some test failures that need to be addressed

vaivaswatha commented 2 weeks ago

@TheDan64 I've fixed the build failures for other versions of LLVM. But there're still tests failing with segfaults that aren't related to my change. I'm not sure what's happening.

vaivaswatha commented 2 weeks ago

@TheDan64 I've fixed the build failures for other versions of LLVM. But there're still tests failing with segfaults that aren't related to my change. I'm not sure what's happening.

btw, I've also added an is_const method for StructValue. The other Value types had this method already.

Would it be a good idea to also provide these methods (is_const, is_undef etc) for AnyValueEnum itself too?