[llvm] r366777 - [LLVM-C] Improve Bindings to The Internalize Pass
Robert Widmann via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 22 21:56:44 PDT 2019
Author: codafi
Date: Mon Jul 22 21:56:44 2019
New Revision: 366777
URL: http://llvm.org/viewvc/llvm-project?rev=366777&view=rev
Log:
[LLVM-C] Improve Bindings to The Internalize Pass
Summary: Adds a binding to the internalize pass that allows the caller to pass a function pointer that acts as the visibility-preservation predicate. Previously, one could only pass an unsigned value (not LLVMBool?) that directed the pass to consider "main" or not.
Reviewers: whitequark, deadalnix, harlanhaskins
Reviewed By: whitequark, harlanhaskins
Subscribers: kren1, hiraditya, llvm-commits, harlanhaskins
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D62456
Modified:
llvm/trunk/include/llvm-c/Transforms/IPO.h
llvm/trunk/lib/Transforms/IPO/IPO.cpp
Modified: llvm/trunk/include/llvm-c/Transforms/IPO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Transforms/IPO.h?rev=366777&r1=366776&r2=366777&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/Transforms/IPO.h (original)
+++ llvm/trunk/include/llvm-c/Transforms/IPO.h Mon Jul 22 21:56:44 2019
@@ -67,6 +67,21 @@ void LLVMAddIPSCCPPass(LLVMPassManagerRe
/** See llvm::createInternalizePass function. */
void LLVMAddInternalizePass(LLVMPassManagerRef, unsigned AllButMain);
+/**
+ * Create and add the internalize pass to the given pass manager with the
+ * provided preservation callback.
+ *
+ * The context parameter is forwarded to the callback on each invocation.
+ * As such, it is the responsibility of the caller to extend its lifetime
+ * until execution of this pass has finished.
+ *
+ * @see llvm::createInternalizePass function.
+ */
+void LLVMAddInternalizePassWithMustPreservePredicate(
+ LLVMPassManagerRef PM,
+ void *Context,
+ LLVMBool (*MustPreserve)(LLVMValueRef, void *));
+
/** See llvm::createStripDeadPrototypesPass function. */
void LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM);
Modified: llvm/trunk/lib/Transforms/IPO/IPO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/IPO.cpp?rev=366777&r1=366776&r2=366777&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/IPO.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/IPO.cpp Mon Jul 22 21:56:44 2019
@@ -121,6 +121,15 @@ void LLVMAddInternalizePass(LLVMPassMana
unwrap(PM)->add(createInternalizePass(PreserveMain));
}
+void LLVMAddInternalizePassWithMustPreservePredicate(
+ LLVMPassManagerRef PM,
+ void *Context,
+ LLVMBool (*Pred)(LLVMValueRef, void *)) {
+ unwrap(PM)->add(createInternalizePass([=](const GlobalValue &GV) {
+ return Pred(wrap(&GV), Context) == 0 ? false : true;
+ }));
+}
+
void LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM) {
unwrap(PM)->add(createStripDeadPrototypesPass());
}
More information about the llvm-commits
mailing list