case IRPosition::IRP_CALL_SITE:
case IRPosition::IRP_CALL_SITE_RETURNED:
case IRPosition::IRP_CALL_SITE_ARGUMENT:
- Attrs = ImmutableCallSite(&IRP.getAnchorValue()).getAttributes();
+ Attrs = cast<CallBase>(IRP.getAnchorValue()).getAttributes();
break;
}
case IRPosition::IRP_CALL_SITE:
case IRPosition::IRP_CALL_SITE_RETURNED:
case IRPosition::IRP_CALL_SITE_ARGUMENT:
- CallSite(&IRP.getAnchorValue()).setAttributes(Attrs);
+ cast<CallBase>(IRP.getAnchorValue()).setAttributes(Attrs);
break;
case IRPosition::IRP_INVALID:
case IRPosition::IRP_FLOAT:
SubsumingPositionIterator::SubsumingPositionIterator(const IRPosition &IRP) {
IRPositions.emplace_back(IRP);
- ImmutableCallSite ICS(&IRP.getAnchorValue());
+ const auto *CB = dyn_cast<CallBase>(&IRP.getAnchorValue());
switch (IRP.getPositionKind()) {
case IRPosition::IRP_INVALID:
case IRPosition::IRP_FLOAT:
IRPositions.emplace_back(IRPosition::function(*IRP.getAnchorScope()));
return;
case IRPosition::IRP_CALL_SITE:
- assert(ICS && "Expected call site!");
+ assert(CB && "Expected call site!");
// TODO: We need to look at the operand bundles similar to the redirection
// in CallBase.
- if (!ICS.hasOperandBundles())
- if (const Function *Callee = ICS.getCalledFunction())
+ if (!CB->hasOperandBundles())
+ if (const Function *Callee = CB->getCalledFunction())
IRPositions.emplace_back(IRPosition::function(*Callee));
return;
case IRPosition::IRP_CALL_SITE_RETURNED:
- assert(ICS && "Expected call site!");
+ assert(CB && "Expected call site!");
// TODO: We need to look at the operand bundles similar to the redirection
// in CallBase.
- if (!ICS.hasOperandBundles()) {
- if (const Function *Callee = ICS.getCalledFunction()) {
+ if (!CB->hasOperandBundles()) {
+ if (const Function *Callee = CB->getCalledFunction()) {
IRPositions.emplace_back(IRPosition::returned(*Callee));
IRPositions.emplace_back(IRPosition::function(*Callee));
for (const Argument &Arg : Callee->args())
if (Arg.hasReturnedAttr()) {
IRPositions.emplace_back(
- IRPosition::callsite_argument(ICS, Arg.getArgNo()));
+ IRPosition::callsite_argument(*CB, Arg.getArgNo()));
IRPositions.emplace_back(
- IRPosition::value(*ICS.getArgOperand(Arg.getArgNo())));
+ IRPosition::value(*CB->getArgOperand(Arg.getArgNo())));
IRPositions.emplace_back(IRPosition::argument(Arg));
}
}
}
- IRPositions.emplace_back(
- IRPosition::callsite_function(cast<CallBase>(*ICS.getInstruction())));
+ IRPositions.emplace_back(IRPosition::callsite_function(*CB));
return;
case IRPosition::IRP_CALL_SITE_ARGUMENT: {
int ArgNo = IRP.getArgNo();
- assert(ICS && ArgNo >= 0 && "Expected call site!");
+ assert(CB && ArgNo >= 0 && "Expected call site!");
// TODO: We need to look at the operand bundles similar to the redirection
// in CallBase.
- if (!ICS.hasOperandBundles()) {
- const Function *Callee = ICS.getCalledFunction();
+ if (!CB->hasOperandBundles()) {
+ const Function *Callee = CB->getCalledFunction();
if (Callee && Callee->arg_size() > unsigned(ArgNo))
IRPositions.emplace_back(IRPosition::argument(*Callee->getArg(ArgNo)));
if (Callee)
return false;
AttributeList AttrList;
- if (ImmutableCallSite ICS = ImmutableCallSite(&getAnchorValue()))
- AttrList = ICS.getAttributes();
+ if (const auto *CB = dyn_cast<CallBase>(&getAnchorValue()))
+ AttrList = CB->getAttributes();
else
AttrList = getAssociatedFunction()->getAttributes();
return isAssumedDead(IRPosition::value(*U.get()), QueryingAA, FnLivenessAA,
CheckBBLivenessOnly, DepClass);
- if (CallSite CS = CallSite(UserI)) {
+ if (auto *CB = dyn_cast<CallBase>(UserI)) {
// For call site argument uses we can check if the argument is
// unused/dead.
- if (CS.isArgOperand(&U)) {
+ if (CB->isArgOperand(&U)) {
const IRPosition &CSArgPos =
- IRPosition::callsite_argument(CS, CS.getArgumentNo(&U));
+ IRPosition::callsite_argument(*CB, CB->getArgOperandNo(&U));
return isAssumedDead(CSArgPos, QueryingAA, FnLivenessAA,
CheckBBLivenessOnly, DepClass);
}
// Note: There are no concrete attributes now so this is initially empty.
switch (I.getOpcode()) {
default:
- assert((!ImmutableCallSite(&I)) && (!isa<CallBase>(&I)) &&
- "New call site/base instruction type needs to be known in the "
+ assert(!isa<CallBase>(&I) &&
+ "New call base instruction type needs to be known in the "
"Attributor.");
break;
case Instruction::Call:
InformationCache::FunctionInfo &FI = InfoCache.getFunctionInfo(F);
if (!isModulePass() && !FI.CalledViaMustTail) {
for (const Use &U : F.uses())
- if (ImmutableCallSite ICS = ImmutableCallSite(U.getUser()))
- if (ICS.isCallee(&U) && ICS.isMustTailCall())
+ if (const auto *CB = dyn_cast<CallBase>(U.getUser()))
+ if (CB->isCallee(&U) && CB->isMustTailCall())
FI.CalledViaMustTail = true;
}
}
auto CallSitePred = [&](Instruction &I) -> bool {
- CallSite CS(&I);
- IRPosition CSRetPos = IRPosition::callsite_returned(CS);
+ auto *CB = dyn_cast<CallBase>(&I);
+ IRPosition CBRetPos = IRPosition::callsite_returned(*CB);
// Call sites might be dead if they do not have side effects and no live
// users. The return value might be dead if there are no live users.
- getOrCreateAAFor<AAIsDead>(CSRetPos);
+ getOrCreateAAFor<AAIsDead>(CBRetPos);
- Function *Callee = CS.getCalledFunction();
+ Function *Callee = CB->getCalledFunction();
// TODO: Even if the callee is not known now we might be able to simplify
// the call/callee.
if (!Callee)
!Callee->hasMetadata(LLVMContext::MD_callback))
return true;
- if (!Callee->getReturnType()->isVoidTy() && !CS->use_empty()) {
+ if (!Callee->getReturnType()->isVoidTy() && !CB->use_empty()) {
- IRPosition CSRetPos = IRPosition::callsite_returned(CS);
+ IRPosition CBRetPos = IRPosition::callsite_returned(*CB);
// Call site return integer values might be limited by a constant range.
if (Callee->getReturnType()->isIntegerTy())
- getOrCreateAAFor<AAValueConstantRange>(CSRetPos);
+ getOrCreateAAFor<AAValueConstantRange>(CBRetPos);
}
- for (int i = 0, e = CS.getNumArgOperands(); i < e; i++) {
+ for (int I = 0, E = CB->getNumArgOperands(); I < E; ++I) {
- IRPosition CSArgPos = IRPosition::callsite_argument(CS, i);
+ IRPosition CBArgPos = IRPosition::callsite_argument(*CB, I);
// Every call site argument might be dead.
- getOrCreateAAFor<AAIsDead>(CSArgPos);
+ getOrCreateAAFor<AAIsDead>(CBArgPos);
// Call site argument might be simplified.
- getOrCreateAAFor<AAValueSimplify>(CSArgPos);
+ getOrCreateAAFor<AAValueSimplify>(CBArgPos);
- if (!CS.getArgument(i)->getType()->isPointerTy())
+ if (!CB->getArgOperand(I)->getType()->isPointerTy())
continue;
// Call site argument attribute "non-null".
- getOrCreateAAFor<AANonNull>(CSArgPos);
+ getOrCreateAAFor<AANonNull>(CBArgPos);
// Call site argument attribute "no-alias".
- getOrCreateAAFor<AANoAlias>(CSArgPos);
+ getOrCreateAAFor<AANoAlias>(CBArgPos);
// Call site argument attribute "dereferenceable".
- getOrCreateAAFor<AADereferenceable>(CSArgPos);
+ getOrCreateAAFor<AADereferenceable>(CBArgPos);
// Call site argument attribute "align".
- getOrCreateAAFor<AAAlign>(CSArgPos);
+ getOrCreateAAFor<AAAlign>(CBArgPos);
// Call site argument attribute
// "readnone/readonly/writeonly/..."
- getOrCreateAAFor<AAMemoryBehavior>(CSArgPos);
+ getOrCreateAAFor<AAMemoryBehavior>(CBArgPos);
// Call site argument attribute "nofree".
- getOrCreateAAFor<AANoFree>(CSArgPos);
+ getOrCreateAAFor<AANoFree>(CBArgPos);
}
return true;
};
// do it eagerly.
if (F->hasLocalLinkage()) {
if (llvm::all_of(F->uses(), [&Functions](const Use &U) {
- ImmutableCallSite ICS(U.getUser());
- return ICS && ICS.isCallee(&U) &&
- Functions.count(const_cast<Function *>(ICS.getCaller()));
+ const auto *CB = dyn_cast<CallBase>(U.getUser());
+ return CB && CB->isCallee(&U) &&
+ Functions.count(const_cast<Function *>(CB->getCaller()));
}))
continue;
}
if (V->getType()->isPointerTy()) {
NewV = V->stripPointerCasts();
} else {
- CallSite CS(V);
- if (CS && CS.getCalledFunction()) {
- for (Argument &Arg : CS.getCalledFunction()->args())
+ auto *CB = dyn_cast<CallBase>(V);
+ if (CB && CB->getCalledFunction()) {
+ for (Argument &Arg : CB->getCalledFunction()->args())
if (Arg.hasReturnedAttr()) {
- NewV = CS.getArgOperand(Arg.getArgNo());
+ NewV = CB->getArgOperand(Arg.getArgNo());
break;
}
}
if (!I.mayThrow())
return true;
- if (ImmutableCallSite ICS = ImmutableCallSite(&I)) {
+ if (const auto *CB = dyn_cast<CallBase>(&I)) {
const auto &NoUnwindAA =
- A.getAAFor<AANoUnwind>(*this, IRPosition::callsite_function(ICS));
+ A.getAAFor<AANoUnwind>(*this, IRPosition::callsite_function(*CB));
return NoUnwindAA.isAssumedNoUnwind();
}
return false;
}
bool AANoSyncImpl::isVolatile(Instruction *I) {
- assert(!ImmutableCallSite(I) && !isa<CallBase>(I) &&
- "Calls should not be checked here");
+ assert(!isa<CallBase>(I) && "Calls should not be checked here");
switch (I->getOpcode()) {
case Instruction::AtomicRMW:
if (isa<IntrinsicInst>(&I) && isNoSyncIntrinsic(&I))
return true;
- if (ImmutableCallSite ICS = ImmutableCallSite(&I)) {
- if (ICS.hasFnAttr(Attribute::NoSync))
+ if (const auto *CB = dyn_cast<CallBase>(&I)) {
+ if (CB->hasFnAttr(Attribute::NoSync))
return true;
const auto &NoSyncAA =
- A.getAAFor<AANoSync>(*this, IRPosition::callsite_function(ICS));
+ A.getAAFor<AANoSync>(*this, IRPosition::callsite_function(*CB));
if (NoSyncAA.isAssumedNoSync())
return true;
return false;
return true;
// non-convergent and readnone imply nosync.
- return !ImmutableCallSite(&I).isConvergent();
+ return !cast<CallBase>(I).isConvergent();
};
if (!A.checkForAllReadWriteInstructions(CheckRWInstForNoSync, *this) ||
/// See AbstractAttribute::updateImpl(...).
ChangeStatus updateImpl(Attributor &A) override {
auto CheckForNoFree = [&](Instruction &I) {
- ImmutableCallSite ICS(&I);
- if (ICS.hasFnAttr(Attribute::NoFree))
+ const auto &CB = cast<CallBase>(I);
+ if (CB.hasFnAttr(Attribute::NoFree))
return true;
const auto &NoFreeAA =
- A.getAAFor<AANoFree>(*this, IRPosition::callsite_function(ICS));
+ A.getAAFor<AANoFree>(*this, IRPosition::callsite_function(CB));
return NoFreeAA.isAssumedNoFree();
};
bool NullPointerIsDefined =
F ? llvm::NullPointerIsDefined(F, PtrTy->getPointerAddressSpace()) : true;
const DataLayout &DL = A.getInfoCache().getDL();
- if (ImmutableCallSite ICS = ImmutableCallSite(I)) {
- if (ICS.isBundleOperand(U))
+ if (const auto *CB = dyn_cast<CallBase>(I)) {
+ if (CB->isBundleOperand(U))
return 0;
- if (ICS.isCallee(U)) {
+ if (CB->isCallee(U)) {
IsNonNull |= !NullPointerIsDefined;
return 0;
}
- unsigned ArgNo = ICS.getArgumentNo(U);
- IRPosition IRP = IRPosition::callsite_argument(ICS, ArgNo);
+ unsigned ArgNo = CB->getArgOperandNo(U);
+ IRPosition IRP = IRPosition::callsite_argument(*CB, ArgNo);
// As long as we only use known information there is no need to track
// dependences here.
auto &DerefAA = A.getAAFor<AADereferenceable>(QueryingAA, IRP,
// If the above check does not hold anymore we look at the calls.
auto CheckForNoRecurse = [&](Instruction &I) {
- ImmutableCallSite ICS(&I);
- if (ICS.hasFnAttr(Attribute::NoRecurse))
+ const auto &CB = cast<CallBase>(I);
+ if (CB.hasFnAttr(Attribute::NoRecurse))
return true;
const auto &NoRecurseAA =
- A.getAAFor<AANoRecurse>(*this, IRPosition::callsite_function(ICS));
+ A.getAAFor<AANoRecurse>(*this, IRPosition::callsite_function(CB));
if (!NoRecurseAA.isAssumedNoRecurse())
return false;
// Recursion to the same function
- if (ICS.getCalledFunction() == getAnchorScope())
+ if (CB.getCalledFunction() == getAnchorScope())
return false;
return true;
/// See AbstractAttribute::updateImpl(...).
ChangeStatus updateImpl(Attributor &A) override {
auto CheckForWillReturn = [&](Instruction &I) {
- IRPosition IPos = IRPosition::callsite_function(ImmutableCallSite(&I));
+ IRPosition IPos = IRPosition::callsite_function(cast<CallBase>(I));
const auto &WillReturnAA = A.getAAFor<AAWillReturn>(*this, IPos);
if (WillReturnAA.isKnownWillReturn())
return true;
/// See AbstractAttribute::initialize(...).
void initialize(Attributor &A) override {
// See callsite argument attribute and callee argument attribute.
- ImmutableCallSite ICS(&getAnchorValue());
- if (ICS.paramHasAttr(getArgNo(), Attribute::NoAlias))
+ const auto &CB = cast<CallBase>(getAnchorValue());
+ if (CB.paramHasAttr(getArgNo(), Attribute::NoAlias))
indicateOptimisticFixpoint();
Value &Val = getAssociatedValue();
if (isa<ConstantPointerNull>(Val) &&
/// \p OtherArgNo of \p ICS (= the underlying call site).
bool mayAliasWithArgument(Attributor &A, AAResults *&AAR,
const AAMemoryBehavior &MemBehaviorAA,
- ImmutableCallSite ICS, unsigned OtherArgNo) {
+ const CallBase &CB, unsigned OtherArgNo) {
// We do not need to worry about aliasing with the underlying IRP.
if (this->getArgNo() == (int)OtherArgNo)
return false;
// If it is not a pointer or pointer vector we do not alias.
- const Value *ArgOp = ICS.getArgOperand(OtherArgNo);
+ const Value *ArgOp = CB.getArgOperand(OtherArgNo);
if (!ArgOp->getType()->isPtrOrPtrVectorTy())
return false;
- auto &ICSArgMemBehaviorAA = A.getAAFor<AAMemoryBehavior>(
- *this, IRPosition::callsite_argument(ICS, OtherArgNo),
+ auto &CBArgMemBehaviorAA = A.getAAFor<AAMemoryBehavior>(
+ *this, IRPosition::callsite_argument(CB, OtherArgNo),
/* TrackDependence */ false);
// If the argument is readnone, there is no read-write aliasing.
- if (ICSArgMemBehaviorAA.isAssumedReadNone()) {
- A.recordDependence(ICSArgMemBehaviorAA, *this, DepClassTy::OPTIONAL);
+ if (CBArgMemBehaviorAA.isAssumedReadNone()) {
+ A.recordDependence(CBArgMemBehaviorAA, *this, DepClassTy::OPTIONAL);
return false;
}
// If the argument is readonly and the underlying value is readonly, there
// is no read-write aliasing.
bool IsReadOnly = MemBehaviorAA.isAssumedReadOnly();
- if (ICSArgMemBehaviorAA.isAssumedReadOnly() && IsReadOnly) {
+ if (CBArgMemBehaviorAA.isAssumedReadOnly() && IsReadOnly) {
A.recordDependence(MemBehaviorAA, *this, DepClassTy::OPTIONAL);
- A.recordDependence(ICSArgMemBehaviorAA, *this, DepClassTy::OPTIONAL);
+ A.recordDependence(CBArgMemBehaviorAA, *this, DepClassTy::OPTIONAL);
return false;
}
// Check there is no other pointer argument which could alias with the
// value passed at this call site.
// TODO: AbstractCallSite
- ImmutableCallSite ICS(&getAnchorValue());
- for (unsigned OtherArgNo = 0; OtherArgNo < ICS.getNumArgOperands();
+ const auto &CB = cast<CallBase>(getAnchorValue());
+ for (unsigned OtherArgNo = 0; OtherArgNo < CB.getNumArgOperands();
OtherArgNo++)
- if (mayAliasWithArgument(A, AAR, MemBehaviorAA, ICS, OtherArgNo))
+ if (mayAliasWithArgument(A, AAR, MemBehaviorAA, CB, OtherArgNo))
return false;
return true;
/// For now, we can only deduce noalias if we have call sites.
/// FIXME: add more support.
- ImmutableCallSite ICS(&RV);
- if (!ICS)
+ if (!isa<CallBase>(&RV))
return false;
const IRPosition &RVPos = IRPosition::value(RV);
// is a performance optimization for blocks with calls to a lot of internal
// functions. It can however cause dead functions to be treated as live.
for (const Instruction &I : BB)
- if (ImmutableCallSite ICS = ImmutableCallSite(&I))
- if (const Function *F = ICS.getCalledFunction())
+ if (const auto *CB = dyn_cast<CallBase>(&I))
+ if (const Function *F = CB->getCalledFunction())
if (F->hasLocalLinkage())
A.markLiveInternalFunction(*F);
return true;
}
MaybeAlign MA;
- if (ImmutableCallSite ICS = ImmutableCallSite(I)) {
- if (ICS.isBundleOperand(U) || ICS.isCallee(U))
+ if (const auto *CB = dyn_cast<CallBase>(I)) {
+ if (CB->isBundleOperand(U) || CB->isCallee(U))
return 0;
- unsigned ArgNo = ICS.getArgumentNo(U);
- IRPosition IRP = IRPosition::callsite_argument(ICS, ArgNo);
+ unsigned ArgNo = CB->getArgOperandNo(U);
+ IRPosition IRP = IRPosition::callsite_argument(*CB, ArgNo);
// As long as we only use known information there is no need to track
// dependences here.
auto &AlignAA = A.getAAFor<AAAlign>(QueryingAA, IRP,
// For now we only use special logic for call sites. However, the tracker
// itself knows about a lot of other non-capturing cases already.
- CallSite CS(UInst);
- if (!CS || !CS.isArgOperand(U))
+ auto *CB = dyn_cast<CallBase>(UInst);
+ if (!CB || !CB->isArgOperand(U))
return isCapturedIn(/* Memory */ true, /* Integer */ true,
/* Return */ true);
- unsigned ArgNo = CS.getArgumentNo(U);
- const IRPosition &CSArgPos = IRPosition::callsite_argument(CS, ArgNo);
+ unsigned ArgNo = CB->getArgOperandNo(U);
+ const IRPosition &CSArgPos = IRPosition::callsite_argument(*CB, ArgNo);
// If we have a abstract no-capture attribute for the argument we can use
// it to justify a non-capture attribute here. This allows recursion!
auto &ArgNoCaptureAA = A.getAAFor<AANoCapture>(NoCaptureAA, CSArgPos);
return isCapturedIn(/* Memory */ false, /* Integer */ false,
/* Return */ false);
if (ArgNoCaptureAA.isAssumedNoCaptureMaybeReturned()) {
- addPotentialCopy(CS);
+ addPotentialCopy(*CB);
return isCapturedIn(/* Memory */ false, /* Integer */ false,
/* Return */ false);
}
}
/// Register \p CS as potential copy of the value we are checking.
- void addPotentialCopy(CallSite CS) {
- PotentialCopies.push_back(CS.getInstruction());
- }
+ void addPotentialCopy(CallBase &CB) { PotentialCopies.push_back(&CB); }
/// See CaptureTracker::shouldExplore(...).
bool shouldExplore(const Use *U) override {
// Helper to check if for the given call site the associated argument is
// passed to a callback where the privatization would be different.
- auto IsCompatiblePrivArgOfCallback = [&](CallSite CS) {
+ auto IsCompatiblePrivArgOfCallback = [&](CallBase &CB) {
SmallVector<const Use *, 4> CallbackUses;
- AbstractCallSite::getCallbackUses(cast<CallBase>(*CS.getInstruction()),
- CallbackUses);
+ AbstractCallSite::getCallbackUses(CB, CallbackUses);
for (const Use *U : CallbackUses) {
AbstractCallSite CBACS(U);
assert(CBACS && CBACS.isCallbackCall());
<< CBArgNo << "@" << CBACS.getCalledFunction()->getName()
<< ")\n[AAPrivatizablePtr] " << CBArg << " : "
<< CBACS.getCallArgOperand(CBArg) << " vs "
- << CS.getArgOperand(ArgNo) << "\n"
+ << CB.getArgOperand(ArgNo) << "\n"
<< "[AAPrivatizablePtr] " << CBArg << " : "
<< CBACS.getCallArgOperandNo(CBArg) << " vs " << ArgNo << "\n";
});
// here.
auto IsCompatiblePrivArgOfOtherCallSite = [&](AbstractCallSite ACS) {
if (ACS.isDirectCall())
- return IsCompatiblePrivArgOfCallback(CallSite(ACS.getInstruction()));
+ return IsCompatiblePrivArgOfCallback(*ACS.getInstruction());
if (ACS.isCallbackCall())
return IsCompatiblePrivArgOfDirectCS(ACS);
return false;
// If the instruction has an own memory behavior state, use it to restrict
// the local state. No further analysis is required as the other memory
// state is as optimistic as it gets.
- if (ImmutableCallSite ICS = ImmutableCallSite(&I)) {
+ if (const auto *CB = dyn_cast<CallBase>(&I)) {
const auto &MemBehaviorAA = A.getAAFor<AAMemoryBehavior>(
- *this, IRPosition::callsite_function(ICS));
+ *this, IRPosition::callsite_function(*CB));
intersectAssumedBits(MemBehaviorAA.getAssumed());
return !isAtFixpoint();
}
// By default we follow all uses assuming UserI might leak information on U,
// we have special handling for call sites operands though.
- ImmutableCallSite ICS(UserI);
- if (!ICS || !ICS.isArgOperand(U))
+ const auto *CB = dyn_cast<CallBase>(UserI);
+ if (!CB || !CB->isArgOperand(U))
return true;
// If the use is a call argument known not to be captured, the users of
// call might the argument "through return", which we allow and for which we
// need to check call users.
if (U->get()->getType()->isPointerTy()) {
- unsigned ArgNo = ICS.getArgumentNo(U);
+ unsigned ArgNo = CB->getArgOperandNo(U);
const auto &ArgNoCaptureAA = A.getAAFor<AANoCapture>(
- *this, IRPosition::callsite_argument(ICS, ArgNo),
+ *this, IRPosition::callsite_argument(*CB, ArgNo),
/* TrackDependence */ true, DepClassTy::OPTIONAL);
return !ArgNoCaptureAA.isAssumedNoCapture();
}
case Instruction::Invoke: {
// For call sites we look at the argument memory behavior attribute (this
// could be recursive!) in order to restrict our own state.
- ImmutableCallSite ICS(UserI);
+ const auto *CB = cast<CallBase>(UserI);
// Give up on operand bundles.
- if (ICS.isBundleOperand(U)) {
+ if (CB->isBundleOperand(U)) {
indicatePessimisticFixpoint();
return;
}
// Calling a function does read the function pointer, maybe write it if the
// function is self-modifying.
- if (ICS.isCallee(U)) {
+ if (CB->isCallee(U)) {
removeAssumedBits(NO_READS);
break;
}
// argument.
IRPosition Pos;
if (U->get()->getType()->isPointerTy())
- Pos = IRPosition::callsite_argument(ICS, ICS.getArgumentNo(U));
+ Pos = IRPosition::callsite_argument(*CB, CB->getArgOperandNo(U));
else
- Pos = IRPosition::callsite_function(ICS);
+ Pos = IRPosition::callsite_function(*CB);
const auto &MemBehaviorAA = A.getAAFor<AAMemoryBehavior>(
*this, Pos,
/* TrackDependence */ true, DepClassTy::OPTIONAL);
Changed);
return true;
}
- if (ImmutableCallSite ICS = ImmutableCallSite(&V)) {
+ if (const auto *CB = dyn_cast<CallBase>(&V)) {
const auto &NoAliasAA =
- A.getAAFor<AANoAlias>(*this, IRPosition::callsite_returned(ICS));
+ A.getAAFor<AANoAlias>(*this, IRPosition::callsite_returned(*CB));
if (NoAliasAA.isAssumedNoAlias()) {
updateStateAndAccessesMap(T, AccessKindAccessesMap, NO_MALLOCED_MEM, &I,
&V, Changed);
AAMemoryLocation::StateType AccessedLocs;
AccessedLocs.intersectAssumedBits(NO_LOCATIONS);
- if (ImmutableCallSite ICS = ImmutableCallSite(&I)) {
+ if (auto *CB = dyn_cast<CallBase>(&I)) {
// First check if we assume any memory is access is visible.
- const auto &ICSMemLocationAA =
- A.getAAFor<AAMemoryLocation>(*this, IRPosition::callsite_function(ICS));
+ const auto &CBMemLocationAA =
+ A.getAAFor<AAMemoryLocation>(*this, IRPosition::callsite_function(*CB));
LLVM_DEBUG(dbgs() << "[AAMemoryLocation] Categorize call site: " << I
- << " [" << ICSMemLocationAA << "]\n");
+ << " [" << CBMemLocationAA << "]\n");
- if (ICSMemLocationAA.isAssumedReadNone())
+ if (CBMemLocationAA.isAssumedReadNone())
return NO_LOCATIONS;
- if (ICSMemLocationAA.isAssumedInaccessibleMemOnly()) {
+ if (CBMemLocationAA.isAssumedInaccessibleMemOnly()) {
updateStateAndAccessesMap(AccessedLocs, AccessKindAccessesMap,
NO_INACCESSIBLE_MEM, &I, nullptr, Changed);
return AccessedLocs.getAssumed();
}
- uint32_t ICSAssumedNotAccessedLocs =
- ICSMemLocationAA.getAssumedNotAccessedLocation();
+ uint32_t CBAssumedNotAccessedLocs =
+ CBMemLocationAA.getAssumedNotAccessedLocation();
// Set the argmemonly and global bit as we handle them separately below.
- uint32_t ICSAssumedNotAccessedLocsNoArgMem =
- ICSAssumedNotAccessedLocs | NO_ARGUMENT_MEM | NO_GLOBAL_MEM;
+ uint32_t CBAssumedNotAccessedLocsNoArgMem =
+ CBAssumedNotAccessedLocs | NO_ARGUMENT_MEM | NO_GLOBAL_MEM;
for (MemoryLocationsKind CurMLK = 1; CurMLK < NO_LOCATIONS; CurMLK *= 2) {
- if (ICSAssumedNotAccessedLocsNoArgMem & CurMLK)
+ if (CBAssumedNotAccessedLocsNoArgMem & CurMLK)
continue;
updateStateAndAccessesMap(AccessedLocs, AccessKindAccessesMap, CurMLK, &I,
nullptr, Changed);
// Now handle global memory if it might be accessed. This is slightly tricky
// as NO_GLOBAL_MEM has multiple bits set.
- bool HasGlobalAccesses = ((~ICSAssumedNotAccessedLocs) & NO_GLOBAL_MEM);
+ bool HasGlobalAccesses = ((~CBAssumedNotAccessedLocs) & NO_GLOBAL_MEM);
if (HasGlobalAccesses) {
auto AccessPred = [&](const Instruction *, const Value *Ptr,
AccessKind Kind, MemoryLocationsKind MLK) {
Ptr, Changed);
return true;
};
- if (!ICSMemLocationAA.checkForAllAccessesToMemoryKind(
+ if (!CBMemLocationAA.checkForAllAccessesToMemoryKind(
AccessPred, inverseLocation(NO_GLOBAL_MEM, false, false)))
return AccessedLocs.getWorstState();
}
<< getMemoryLocationsAsStr(AccessedLocs.getAssumed()) << "\n");
// Now handle argument memory if it might be accessed.
- bool HasArgAccesses = ((~ICSAssumedNotAccessedLocs) & NO_ARGUMENT_MEM);
+ bool HasArgAccesses = ((~CBAssumedNotAccessedLocs) & NO_ARGUMENT_MEM);
if (HasArgAccesses) {
- for (unsigned ArgNo = 0, e = ICS.getNumArgOperands(); ArgNo < e;
+ for (unsigned ArgNo = 0, E = CB->getNumArgOperands(); ArgNo < E;
++ArgNo) {
// Skip non-pointer arguments.
- const Value *ArgOp = ICS.getArgOperand(ArgNo);
+ const Value *ArgOp = CB->getArgOperand(ArgNo);
if (!ArgOp->getType()->isPtrOrPtrVectorTy())
continue;
// Skip readnone arguments.
- const IRPosition &ArgOpIRP = IRPosition::callsite_argument(ICS, ArgNo);
+ const IRPosition &ArgOpIRP = IRPosition::callsite_argument(*CB, ArgNo);
const auto &ArgOpMemLocationAA = A.getAAFor<AAMemoryBehavior>(
*this, ArgOpIRP, /* TrackDependence */ true, DepClassTy::OPTIONAL);