#include "llvm/IR/Operator.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/Pass.h"
-#include "llvm/Transforms/Utils/SimplifyLibCalls.h"
#define DEBUG_TYPE "instcombine"
DominatorTree *DT;
LoopInfo *LI;
bool MadeIRChange;
- LibCallSimplifier *Simplifier;
bool MinimizeSize;
public:
#include "llvm/IR/Statepoint.h"
#include "llvm/Transforms/Utils/BuildLibCalls.h"
#include "llvm/Transforms/Utils/Local.h"
+#include "llvm/Transforms/Utils/SimplifyLibCalls.h"
using namespace llvm;
using namespace PatternMatch;
Instruction *InstCombiner::tryOptimizeCall(CallInst *CI, const DataLayout *DL) {
if (!CI->getCalledFunction()) return nullptr;
- if (Value *With = Simplifier->optimizeCall(CI)) {
+ auto InstCombineRAUW = [this](Instruction *From, Value *With) {
+ ReplaceInstUsesWith(*From, With);
+ };
+ LibCallSimplifier Simplifier(DL, TLI, InstCombineRAUW);
+ if (Value *With = Simplifier.optimizeCall(CI)) {
++NumSimplified;
return CI->use_empty() ? CI : ReplaceInstUsesWith(*CI, With);
}
F.getContext(), TargetFolder(DL), InstCombineIRInserter(Worklist, AC));
Builder = &TheBuilder;
- auto InstCombineRAUW = [this](Instruction *From, Value *With) {
- ReplaceInstUsesWith(*From, With);
- };
- LibCallSimplifier TheSimplifier(DL, TLI, InstCombineRAUW);
- Simplifier = &TheSimplifier;
-
bool EverMadeChange = false;
// Lower dbg.declare intrinsics otherwise their value may be clobbered