case Instruction::FCmp: llvm_unreachable("Invalid for compares");
case Instruction::Call:
if (auto *F = dyn_cast<Function>(Ops.back())) {
- ImmutableCallSite CS(cast<CallInst>(InstOrCE));
- if (canConstantFoldCallTo(CS, F))
- return ConstantFoldCall(CS, F, Ops.slice(0, Ops.size() - 1), TLI);
+ const auto *Call = cast<CallBase>(InstOrCE);
+ if (canConstantFoldCallTo(Call, F))
+ return ConstantFoldCall(Call, F, Ops.slice(0, Ops.size() - 1), TLI);
}
return nullptr;
case Instruction::Select:
// Constant Folding for Calls
//
-bool llvm::canConstantFoldCallTo(ImmutableCallSite CS, const Function *F) {
- if (CS.isNoBuiltin() || CS.isStrictFP())
+bool llvm::canConstantFoldCallTo(const CallBase *Call, const Function *F) {
+ if (Call->isNoBuiltin() || Call->isStrictFP())
return false;
switch (F->getIntrinsicID()) {
case Intrinsic::fabs:
Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID, Type *Ty,
ArrayRef<Constant *> Operands,
const TargetLibraryInfo *TLI,
- ImmutableCallSite CS) {
+ const CallBase *Call) {
if (Operands.size() == 1) {
if (IntrinsicID == Intrinsic::is_constant) {
// We know we have a "Constant" argument. But we want to only
if (IntrinsicID == Intrinsic::launder_invariant_group ||
IntrinsicID == Intrinsic::strip_invariant_group) {
// If instruction is not yet put in a basic block (e.g. when cloning
- // a function during inlining), CS caller may not be available.
- // So check CS's BB first before querying CS.getCaller.
- const Function *Caller = CS.getParent() ? CS.getCaller() : nullptr;
+ // a function during inlining), Call's caller may not be available.
+ // So check Call's BB first before querying Call->getCaller.
+ const Function *Caller =
+ Call->getParent() ? Call->getCaller() : nullptr;
if (Caller &&
!NullPointerIsDefined(
Caller, Operands[0]->getType()->getPointerAddressSpace())) {
VectorType *VTy, ArrayRef<Constant *> Operands,
const DataLayout &DL,
const TargetLibraryInfo *TLI,
- ImmutableCallSite CS) {
+ const CallBase *Call) {
SmallVector<Constant *, 4> Result(VTy->getNumElements());
SmallVector<Constant *, 4> Lane(Operands.size());
Type *Ty = VTy->getElementType();
}
// Use the regular scalar folding to simplify this column.
- Constant *Folded = ConstantFoldScalarCall(Name, IntrinsicID, Ty, Lane, TLI, CS);
+ Constant *Folded =
+ ConstantFoldScalarCall(Name, IntrinsicID, Ty, Lane, TLI, Call);
if (!Folded)
return nullptr;
Result[I] = Folded;
} // end anonymous namespace
-Constant *
-llvm::ConstantFoldCall(ImmutableCallSite CS, Function *F,
- ArrayRef<Constant *> Operands,
- const TargetLibraryInfo *TLI) {
- if (CS.isNoBuiltin() || CS.isStrictFP())
+Constant *llvm::ConstantFoldCall(const CallBase *Call, Function *F,
+ ArrayRef<Constant *> Operands,
+ const TargetLibraryInfo *TLI) {
+ if (Call->isNoBuiltin() || Call->isStrictFP())
return nullptr;
if (!F->hasName())
return nullptr;
if (auto *VTy = dyn_cast<VectorType>(Ty))
return ConstantFoldVectorCall(Name, F->getIntrinsicID(), VTy, Operands,
- F->getParent()->getDataLayout(), TLI, CS);
+ F->getParent()->getDataLayout(), TLI, Call);
- return ConstantFoldScalarCall(Name, F->getIntrinsicID(), Ty, Operands, TLI, CS);
+ return ConstantFoldScalarCall(Name, F->getIntrinsicID(), Ty, Operands, TLI,
+ Call);
}
-bool llvm::isMathLibCallNoop(CallSite CS, const TargetLibraryInfo *TLI) {
+bool llvm::isMathLibCallNoop(const CallBase *Call,
+ const TargetLibraryInfo *TLI) {
// FIXME: Refactor this code; this duplicates logic in LibCallsShrinkWrap
// (and to some extent ConstantFoldScalarCall).
- if (CS.isNoBuiltin() || CS.isStrictFP())
+ if (Call->isNoBuiltin() || Call->isStrictFP())
return false;
- Function *F = CS.getCalledFunction();
+ Function *F = Call->getCalledFunction();
if (!F)
return false;
if (!TLI || !TLI->getLibFunc(*F, Func))
return false;
- if (CS.getNumArgOperands() == 1) {
- if (ConstantFP *OpC = dyn_cast<ConstantFP>(CS.getArgOperand(0))) {
+ if (Call->getNumArgOperands() == 1) {
+ if (ConstantFP *OpC = dyn_cast<ConstantFP>(Call->getArgOperand(0))) {
const APFloat &Op = OpC->getValueAPF();
switch (Func) {
case LibFunc_logl:
}
}
- if (CS.getNumArgOperands() == 2) {
- ConstantFP *Op0C = dyn_cast<ConstantFP>(CS.getArgOperand(0));
- ConstantFP *Op1C = dyn_cast<ConstantFP>(CS.getArgOperand(1));
+ if (Call->getNumArgOperands() == 2) {
+ ConstantFP *Op0C = dyn_cast<ConstantFP>(Call->getArgOperand(0));
+ ConstantFP *Op1C = dyn_cast<ConstantFP>(Call->getArgOperand(1));
if (Op0C && Op1C) {
const APFloat &Op0 = Op0C->getValueAPF();
const APFloat &Op1 = Op1C->getValueAPF();