You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Another simpler solution (but may be not so elegant) would be to just validate that the indices are valid for the provided pointer type.
This will require re-implementing something like GetElementPtrIns::getIndexedType. Note that the llvm-c API doesn't expose that method. (I tried to ask if they are willing to have it exposed, but they seemed reluctant).
With such a function, we could evaluate whether the indices are valid, and only then call LLVM's gep builder, being sure that the asserts won't hit.
The doc comment on the method has the following statement.
Wrong GEP indices leads to asserts (on debug builds of LLVM), and is perhaps a good enough reason to not have
unsafe
for this method.Alternatively, a new inkwell datatype can be introduced for GEP indices, to make them safer. Something similar was done in Haskell. See https://luctielen.com/posts/making_llvm_gep_safer_in_haskell/.
The text was updated successfully, but these errors were encountered: