- Add a missing getter for module-level inline assembly
- Add a missing append function for module-level inline assembly
- Deprecate LLVMSetModuleInlineAsm and replace it with LLVMSetModuleInlineAsm2 which takes an explicit length parameter
- Deprecate LLVMConstInlineAsm and replace it with LLVMGetInlineAsm, a function that allows passing a dialect and is not mis-classified as a constant operation
Details
Diff Detail
Event Timeline
The original API for LLVMSetModuleInlineAsm implies that only C-style strings can be passed here, but the implementation is copying to a std::string under the hood anyhow. If that's the invariant that we want to maintain here, I will revert the deprecation and add documentation.
Excellent work, thanks!
Regarding LLVMSetModuleInlineAsm2, I have two thoughts:
- It is likely that actually passing a literal \0 in inline assembly will confuse the assembler. In fact, I think both internal and external assemblers will refuse to process it.
- Silently truncating on \0 is likely to hide a bug elsewhere instead, so an explicit error is good.
- Consistency with other APIs is good, and making the job of FFI bindings easier is also good (some of them autogenerate code from signatures).
- Code churn is bad, and in this case even the above isn't a particularly strong justification for code churn.
As a result, I think we should merge this as-is, but do not take aggressive steps to remove LLVMSetModuleInlineAsm. It is enough that all new code will use LLVMSetModuleInlineAsm2.
Oh sorry, I've missed one API issue.
include/llvm-c/Core.h | ||
---|---|---|
684 | I think this should be const char *AsmString, size_t AsmStringSize, const char *Constraints, size_t ConstraintsSize. |
include/llvm-c/Core.h | ||
---|---|---|
684 | Or rather const char *AsmString, size_t AsmStringLen, const char *Constraints, size_t ConstraintsLen. |
include/llvm-c/Core.h | ||
---|---|---|
684 | Aha, good catch. |
I think this should be const char *AsmString, size_t AsmStringSize, const char *Constraints, size_t ConstraintsSize.