From 477cc8323193a5d7b35cb7bb63658a5fc3b25d44 Mon Sep 17 00:00:00 2001 From: Robert Widmann Date: Tue, 1 Jan 2019 18:56:51 +0000 Subject: [PATCH] [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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350196 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 17 +++++++++++++++++ lib/IR/Core.cpp | 8 ++++++++ 2 files changed, 25 insertions(+) diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index 0784275ace8..ebf79a421c9 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -520,6 +520,23 @@ void *LLVMContextGetDiagnosticContext(LLVMContextRef C); void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback, 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. * diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp index a3065733c81..77d93ddfc11 100644 --- a/lib/IR/Core.cpp +++ b/lib/IR/Core.cpp @@ -108,6 +108,14 @@ void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback, 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); } -- 2.50.1