[PATCH] D96792: [llvm-c] Add C API wrapper for addModuleFlag overload that takes an int32_t value

Dhruv Rajvanshi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 16 08:57:33 PST 2021


dhruvrajvanshi created this revision.
dhruvrajvanshi added a reviewer: echristo.
dhruvrajvanshi added projects: LLVM, debug-info.
Herald added a reviewer: deadalnix.
Herald added subscribers: dexonsmith, hiraditya.
dhruvrajvanshi requested review of this revision.
Herald added a subscriber: llvm-commits.

This API wasn't exposed from llvm-c, which made it harder to add debug info to modules.

I'm not a 100% sure about the name so I can change it if required.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96792

Files:
  llvm/include/llvm-c/Core.h
  llvm/lib/IR/Core.cpp


Index: llvm/lib/IR/Core.cpp
===================================================================
--- llvm/lib/IR/Core.cpp
+++ 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) {
Index: llvm/include/llvm-c/Core.h
===================================================================
--- llvm/include/llvm-c/Core.h
+++ 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.
  *


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96792.324020.patch
Type: text/x-patch
Size: 1257 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210216/4e7fd3b9/attachment.bin>


More information about the llvm-commits mailing list