mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-14 14:24:05 +00:00
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226640 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user