TheDan64 / inkwell

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

Implement safe API for operand bundles. #524

Closed airwoodix closed 2 months ago

airwoodix commented 3 months ago

Description

Implement a safe API wrapping the operand bundles manipulation calls in llvm-sys. The feature requires llvm18+.

Building call instructions is done with the new Builder::build_direct_call_with_operand_bundles and Builder::build_indirect_call_with_operand_bundles.

Since only call and invoke instructions support operand bundles, introspection methods are implemented on CallSiteValue. CallSiteValue::get_operand_bundles() produces an iterator of OperandBundle values, and OperandBundle::get_args() iterates over a bundle's arguments. OperandBundle::tag() retrieves the bundle's tag as a string slice.

Related Issue

Resolves #523

How This Has Been Tested

Ran tests for LLVM 16 and 18.

Checklist

airwoodix commented 3 months ago

There's no CI environment for LLVM18 (was mentioned in https://github.com/TheDan64/inkwell/pull/483#issuecomment-2028912400). Should this be added in a separate PR?

TheDan64 commented 3 months ago

Yes, separate PR please