diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h --- a/llvm/include/llvm-c/Core.h +++ b/llvm/include/llvm-c/Core.h @@ -810,6 +810,15 @@ const char *Key, size_t KeyLen, LLVMMetadataRef Val); +/** + * Add a module-level flag to the module-level flags metadata if it doesn't + * already exist. + * + * @see Module::addModuleFlag() + */ +void LLVMAddRawModuleFlag(LLVMModuleRef M, LLVMModuleFlagBehavior, + const char *Key, size_t KeyLen, int32_t Val); + /** * Dump a representation of a module to stderr. * diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -386,6 +386,12 @@ {Key, KeyLen}, unwrap(Val)); } +void LLVMAddRawModuleFlag(LLVMModuleRef M, LLVMModuleFlagBehavior Behavior, + const char *Key, size_t KeyLen, int32_t Val) { + unwrap(M)->addModuleFlag(map_to_llvmModFlagBehavior(Behavior), {Key, KeyLen}, + Val); +} + /*--.. Printing modules ....................................................--*/ void LLVMDumpModule(LLVMModuleRef M) {