Skip to content

Commit

Permalink
[CallSite removal][ValueTracking] Use CallBase instead of ImmutableCa…
Browse files Browse the repository at this point in the history
…llSite for getIntrinsicForCallSite. NFC

Differential Revision: https://reviews.llvm.org/D78613
  • Loading branch information
topperc committed Apr 22, 2020
1 parent 411a254 commit be04aba
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions llvm/include/llvm/Analysis/ValueTracking.h
Expand Up @@ -17,10 +17,9 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Intrinsics.h"
#include <cassert>
#include <cstdint>
Expand All @@ -33,6 +32,7 @@ class AssumptionCache;
class DominatorTree;
class GEPOperator;
class IntrinsicInst;
class LoadInst;
class WithOverflowInst;
struct KnownBits;
class Loop;
Expand Down Expand Up @@ -210,7 +210,7 @@ class Value;

/// Map a call instruction to an intrinsic ID. Libcalls which have equivalent
/// intrinsics are treated as-if they were intrinsics.
Intrinsic::ID getIntrinsicForCallSite(ImmutableCallSite ICS,
Intrinsic::ID getIntrinsicForCallSite(const CallBase &CB,
const TargetLibraryInfo *TLI);

/// Return true if we can prove that the specified FP value is never equal to
Expand Down
10 changes: 5 additions & 5 deletions llvm/lib/Analysis/ValueTracking.cpp
Expand Up @@ -3074,9 +3074,9 @@ bool llvm::ComputeMultiple(Value *V, unsigned Base, Value *&Multiple,
return false;
}

Intrinsic::ID llvm::getIntrinsicForCallSite(ImmutableCallSite ICS,
Intrinsic::ID llvm::getIntrinsicForCallSite(const CallBase &CB,
const TargetLibraryInfo *TLI) {
const Function *F = ICS.getCalledFunction();
const Function *F = CB.getCalledFunction();
if (!F)
return Intrinsic::not_intrinsic;

Expand All @@ -3093,7 +3093,7 @@ Intrinsic::ID llvm::getIntrinsicForCallSite(ImmutableCallSite ICS,
if (!F || F->hasLocalLinkage() || !TLI->getLibFunc(*F, Func))
return Intrinsic::not_intrinsic;

if (!ICS.onlyReadsMemory())
if (!CB.onlyReadsMemory())
return Intrinsic::not_intrinsic;

// Otherwise check if we have a call to a function that can be turned into a
Expand Down Expand Up @@ -3214,7 +3214,7 @@ bool llvm::CannotBeNegativeZero(const Value *V, const TargetLibraryInfo *TLI,
return true;

if (auto *Call = dyn_cast<CallInst>(Op)) {
Intrinsic::ID IID = getIntrinsicForCallSite(Call, TLI);
Intrinsic::ID IID = getIntrinsicForCallSite(*Call, TLI);
switch (IID) {
default:
break;
Expand Down Expand Up @@ -3311,7 +3311,7 @@ static bool cannotBeOrderedLessThanZeroImpl(const Value *V,
Depth + 1);
case Instruction::Call:
const auto *CI = cast<CallInst>(I);
Intrinsic::ID IID = getIntrinsicForCallSite(CI, TLI);
Intrinsic::ID IID = getIntrinsicForCallSite(*CI, TLI);
switch (IID) {
default:
break;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/VectorUtils.cpp
Expand Up @@ -112,7 +112,7 @@ bool llvm::hasVectorInstrinsicScalarOpd(Intrinsic::ID ID,
/// its ID, in case it does not found it return not_intrinsic.
Intrinsic::ID llvm::getVectorIntrinsicIDForCall(const CallInst *CI,
const TargetLibraryInfo *TLI) {
Intrinsic::ID ID = getIntrinsicForCallSite(CI, TLI);
Intrinsic::ID ID = getIntrinsicForCallSite(*CI, TLI);
if (ID == Intrinsic::not_intrinsic)
return Intrinsic::not_intrinsic;

Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Transforms/IPO/IPConstantPropagation.cpp
Expand Up @@ -17,6 +17,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Transforms/Scalar/SpeculateAroundPHIs.cpp
Expand Up @@ -14,6 +14,7 @@
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
Expand Down
1 change: 1 addition & 0 deletions llvm/unittests/Analysis/ValueTrackingTest.cpp
Expand Up @@ -10,6 +10,7 @@
#include "llvm/AsmParser/Parser.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/ErrorHandling.h"
Expand Down

0 comments on commit be04aba

Please sign in to comment.