summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2015-01-21 02:11:59 +0000
committerChandler Carruth <chandlerc@gmail.com>2015-01-21 02:11:59 +0000
commit9280382ac6f023efd009c99c0b522a9edbeb6152 (patch)
tree5f4172c13b8dd98b03c2465312ff77acd1ba02b3 /llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
parent82b58712c119a2d0ab354cac0c3d80554bd3e741 (diff)
downloadbcm5719-llvm-9280382ac6f023efd009c99c0b522a9edbeb6152.tar.gz
bcm5719-llvm-9280382ac6f023efd009c99c0b522a9edbeb6152.zip
[PM] Replace an abuse of inheritance to override a single function with
a more direct approach: a type-erased glorified function pointer. Now we can pass a function pointer into this for the easy case and we can even pass a lambda into it in the interesting case in the instruction combiner. I'll be using this shortly to simplify the interfaces to InstCombiner, but this helps pave the way and seems like a better design for the libcall simplifier utility. llvm-svn: 226640
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 76d5cc4917d..13c2365e1ef 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -2084,15 +2084,19 @@ Value *LibCallSimplifier::optimizeCall(CallInst *CI) {
return nullptr;
}
-LibCallSimplifier::LibCallSimplifier(const DataLayout *DL,
- const TargetLibraryInfo *TLI) :
- FortifiedSimplifier(DL, TLI),
- DL(DL),
- TLI(TLI),
- UnsafeFPShrink(false) {
+LibCallSimplifier::LibCallSimplifier(
+ const DataLayout *DL, const TargetLibraryInfo *TLI,
+ function_ref<void(Instruction *, Value *)> Replacer)
+ : FortifiedSimplifier(DL, TLI), DL(DL), TLI(TLI), UnsafeFPShrink(false),
+ Replacer(Replacer) {}
+
+void LibCallSimplifier::replaceAllUsesWith(Instruction *I, Value *With) {
+ // Indirect through the replacer used in this instance.
+ Replacer(I, With);
}
-void LibCallSimplifier::replaceAllUsesWith(Instruction *I, Value *With) const {
+/*static*/ void LibCallSimplifier::replaceAllUsesWithDefault(Instruction *I,
+ Value *With) {
I->replaceAllUsesWith(With);
I->eraseFromParent();
}
OpenPOWER on IntegriCloud