[llvm] r350196 - [LLVM-C] Add Accessors for Discarding Value Names in the IR

Robert Widmann via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 1 10:56:51 PST 2019


Author: codafi
Date: Tue Jan  1 10:56:51 2019
New Revision: 350196

URL: http://llvm.org/viewvc/llvm-project?rev=350196&view=rev
Log:
[LLVM-C] Add Accessors for Discarding Value Names in the IR

Summary: Add accessors so the performance improvement from this setting is accessible to third parties.

Reviewers: whitequark, deadalnix

Reviewed By: whitequark

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D56179

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

Modified: llvm/trunk/include/llvm-c/Core.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=350196&r1=350195&r2=350196&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/Core.h (original)
+++ llvm/trunk/include/llvm-c/Core.h Tue Jan  1 10:56:51 2019
@@ -521,6 +521,23 @@ void LLVMContextSetYieldCallback(LLVMCon
                                  void *OpaqueHandle);
 
 /**
+ * Retrieve whether the given context is set to discard all value names.
+ *
+ * @see LLVMContext::shouldDiscardValueNames()
+ */
+bool LLVMContextShouldDiscardValueNames(LLVMContextRef C);
+
+/**
+ * Set whether the given context discards all value names.
+ *
+ * If true, only the names of GlobalValue objects will be available in the IR.
+ * This can be used to save memory and runtime, especially in release mode.
+ *
+ * @see LLVMContext::setDiscardValueNames()
+ */
+void LLVMContextSetDiscardValueNames(LLVMContextRef C, bool Discard);
+
+/**
  * Destroy a context instance.
  *
  * This should be called for every call to LLVMContextCreate() or memory

Modified: llvm/trunk/lib/IR/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Core.cpp?rev=350196&r1=350195&r2=350196&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Core.cpp (original)
+++ llvm/trunk/lib/IR/Core.cpp Tue Jan  1 10:56:51 2019
@@ -108,6 +108,14 @@ void LLVMContextSetYieldCallback(LLVMCon
   unwrap(C)->setYieldCallback(YieldCallback, OpaqueHandle);
 }
 
+bool LLVMContextShouldDiscardValueNames(LLVMContextRef C) {
+  return unwrap(C)->shouldDiscardValueNames();
+}
+
+void LLVMContextSetDiscardValueNames(LLVMContextRef C, bool Discard) {
+  unwrap(C)->setDiscardValueNames(Discard);
+}
+
 void LLVMContextDispose(LLVMContextRef C) {
   delete unwrap(C);
 }




More information about the llvm-commits mailing list