[PATCH] D62456: [LLVM-C] Improve Bindings to The Internalize Pass
Robert Widmann via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat May 25 14:20:50 PDT 2019
CodaFi created this revision.
CodaFi added reviewers: whitequark, deadalnix.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D62456
Files:
llvm/include/llvm-c/Transforms/IPO.h
llvm/lib/Transforms/IPO/IPO.cpp
Index: llvm/lib/Transforms/IPO/IPO.cpp
===================================================================
--- llvm/lib/Transforms/IPO/IPO.cpp
+++ llvm/lib/Transforms/IPO/IPO.cpp
@@ -120,6 +120,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());
}
Index: llvm/include/llvm-c/Transforms/IPO.h
===================================================================
--- llvm/include/llvm-c/Transforms/IPO.h
+++ llvm/include/llvm-c/Transforms/IPO.h
@@ -67,6 +67,12 @@
/** See llvm::createInternalizePass function. */
void LLVMAddInternalizePass(LLVMPassManagerRef, unsigned AllButMain);
+/** See llvm::createInternalizePass function. */
+void LLVMAddInternalizePassWithMustPreservePredicate(
+ LLVMPassManagerRef PM,
+ void *Context,
+ LLVMBool (*MustPreserve)(LLVMValueRef, void *));
+
/** See llvm::createStripDeadPrototypesPass function. */
void LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62456.201423.patch
Type: text/x-patch
Size: 1337 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190525/bc70885e/attachment.bin>
More information about the llvm-commits
mailing list