summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine
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/InstCombine
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/InstCombine')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstructionCombining.cpp24
1 files changed, 4 insertions, 20 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index a012be0669a..33f024b2729 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -2919,25 +2919,6 @@ bool InstCombiner::DoOneIteration(Function &F, unsigned Iteration) {
return MadeIRChange;
}
-namespace {
-class InstCombinerLibCallSimplifier final : public LibCallSimplifier {
- InstCombiner *IC;
-public:
- InstCombinerLibCallSimplifier(const DataLayout *DL,
- const TargetLibraryInfo *TLI,
- InstCombiner *IC)
- : LibCallSimplifier(DL, TLI) {
- this->IC = IC;
- }
-
- /// replaceAllUsesWith - override so that instruction replacement
- /// can be defined in terms of the instruction combiner framework.
- void replaceAllUsesWith(Instruction *I, Value *With) const override {
- IC->ReplaceInstUsesWith(*I, With);
- }
-};
-}
-
// FIXME: Passing all of the analyses here in the run method is ugly. We should
// separate out the worklist from the combiner so that we can construct
// a combiner once per function while re-using the storage of an external
@@ -2962,7 +2943,10 @@ bool InstCombiner::run(Function &F, AssumptionCache *AC, const DataLayout *DL,
F.getContext(), TargetFolder(DL), InstCombineIRInserter(Worklist, AC));
Builder = &TheBuilder;
- InstCombinerLibCallSimplifier TheSimplifier(DL, TLI, this);
+ auto InstCombineRAUW = [this](Instruction *From, Value *With) {
+ ReplaceInstUsesWith(*From, With);
+ };
+ LibCallSimplifier TheSimplifier(DL, TLI, InstCombineRAUW);
Simplifier = &TheSimplifier;
bool EverMadeChange = false;
OpenPOWER on IntegriCloud