[PATCH] D62456: [LLVM-C] Improve Bindings to The Internalize Pass

Robert Widmann via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 22 21:57:51 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL366777: [LLVM-C] Improve Bindings to The Internalize Pass (authored by CodaFi, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62456?vs=201429&id=211248#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62456/new/

https://reviews.llvm.org/D62456

Files:
  llvm/trunk/include/llvm-c/Transforms/IPO.h
  llvm/trunk/lib/Transforms/IPO/IPO.cpp


Index: llvm/trunk/include/llvm-c/Transforms/IPO.h
===================================================================
--- llvm/trunk/include/llvm-c/Transforms/IPO.h
+++ llvm/trunk/include/llvm-c/Transforms/IPO.h
@@ -67,6 +67,21 @@
 /** 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);
 
Index: llvm/trunk/lib/Transforms/IPO/IPO.cpp
===================================================================
--- llvm/trunk/lib/Transforms/IPO/IPO.cpp
+++ llvm/trunk/lib/Transforms/IPO/IPO.cpp
@@ -121,6 +121,15 @@
   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());
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62456.211248.patch
Type: text/x-patch
Size: 1696 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190723/902dbe2b/attachment.bin>


More information about the llvm-commits mailing list