Skip to content

Commit

Permalink
Remove unused parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
ahatanaka committed Nov 3, 2020
1 parent f82d307 commit b0f1d7d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 27 deletions.
14 changes: 4 additions & 10 deletions llvm/lib/Transforms/ObjCARC/DependencyAnalysis.cpp
Expand Up @@ -51,10 +51,8 @@ bool llvm::objcarc::CanAlterRefCount(const Instruction *Inst, const Value *Ptr,
if (AliasAnalysis::onlyReadsMemory(MRB))
return false;
if (AliasAnalysis::onlyAccessesArgPointees(MRB)) {
const DataLayout &DL = Inst->getModule()->getDataLayout();
for (const Value *Op : Call->args()) {
if (IsPotentialRetainableObjPtr(Op, *PA.getAA()) &&
PA.related(Ptr, Op, DL))
if (IsPotentialRetainableObjPtr(Op, *PA.getAA()) && PA.related(Ptr, Op))
return true;
}
return false;
Expand Down Expand Up @@ -85,8 +83,6 @@ bool llvm::objcarc::CanUse(const Instruction *Inst, const Value *Ptr,
if (Class == ARCInstKind::Call)
return false;

const DataLayout &DL = Inst->getModule()->getDataLayout();

// Consider various instructions which may have pointer arguments which are
// not "uses".
if (const ICmpInst *ICI = dyn_cast<ICmpInst>(Inst)) {
Expand All @@ -99,8 +95,7 @@ bool llvm::objcarc::CanUse(const Instruction *Inst, const Value *Ptr,
// For calls, just check the arguments (and not the callee operand).
for (auto OI = CS->arg_begin(), OE = CS->arg_end(); OI != OE; ++OI) {
const Value *Op = *OI;
if (IsPotentialRetainableObjPtr(Op, *PA.getAA()) &&
PA.related(Ptr, Op, DL))
if (IsPotentialRetainableObjPtr(Op, *PA.getAA()) && PA.related(Ptr, Op))
return true;
}
return false;
Expand All @@ -110,15 +105,14 @@ bool llvm::objcarc::CanUse(const Instruction *Inst, const Value *Ptr,
const Value *Op = GetUnderlyingObjCPtr(SI->getPointerOperand());
// If we can't tell what the underlying object was, assume there is a
// dependence.
return IsPotentialRetainableObjPtr(Op, *PA.getAA()) &&
PA.related(Op, Ptr, DL);
return IsPotentialRetainableObjPtr(Op, *PA.getAA()) && PA.related(Op, Ptr);
}

// Check each operand for a match.
for (User::const_op_iterator OI = Inst->op_begin(), OE = Inst->op_end();
OI != OE; ++OI) {
const Value *Op = *OI;
if (IsPotentialRetainableObjPtr(Op, *PA.getAA()) && PA.related(Ptr, Op, DL))
if (IsPotentialRetainableObjPtr(Op, *PA.getAA()) && PA.related(Ptr, Op))
return true;
}
return false;
Expand Down
21 changes: 8 additions & 13 deletions llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.cpp
Expand Up @@ -40,38 +40,35 @@ using namespace llvm::objcarc;

bool ProvenanceAnalysis::relatedSelect(const SelectInst *A,
const Value *B) {
const DataLayout &DL = A->getModule()->getDataLayout();
// If the values are Selects with the same condition, we can do a more precise
// check: just check for relations between the values on corresponding arms.
if (const SelectInst *SB = dyn_cast<SelectInst>(B))
if (A->getCondition() == SB->getCondition())
return related(A->getTrueValue(), SB->getTrueValue(), DL) ||
related(A->getFalseValue(), SB->getFalseValue(), DL);
return related(A->getTrueValue(), SB->getTrueValue()) ||
related(A->getFalseValue(), SB->getFalseValue());

// Check both arms of the Select node individually.
return related(A->getTrueValue(), B, DL) ||
related(A->getFalseValue(), B, DL);
return related(A->getTrueValue(), B) || related(A->getFalseValue(), B);
}

bool ProvenanceAnalysis::relatedPHI(const PHINode *A,
const Value *B) {
const DataLayout &DL = A->getModule()->getDataLayout();
// If the values are PHIs in the same block, we can do a more precise as well
// as efficient check: just check for relations between the values on
// corresponding edges.
if (const PHINode *PNB = dyn_cast<PHINode>(B))
if (PNB->getParent() == A->getParent()) {
for (unsigned i = 0, e = A->getNumIncomingValues(); i != e; ++i)
if (related(A->getIncomingValue(i),
PNB->getIncomingValueForBlock(A->getIncomingBlock(i)), DL))
PNB->getIncomingValueForBlock(A->getIncomingBlock(i))))
return true;
return false;
}

// Check each unique source of the PHI node against B.
SmallPtrSet<const Value *, 4> UniqueSrc;
for (Value *PV1 : A->incoming_values()) {
if (UniqueSrc.insert(PV1).second && related(PV1, B, DL))
if (UniqueSrc.insert(PV1).second && related(PV1, B))
return true;
}

Expand Down Expand Up @@ -112,8 +109,7 @@ static bool IsStoredObjCPointer(const Value *P) {
return false;
}

bool ProvenanceAnalysis::relatedCheck(const Value *A, const Value *B,
const DataLayout &DL) {
bool ProvenanceAnalysis::relatedCheck(const Value *A, const Value *B) {
// Ask regular AliasAnalysis, for a first approximation.
switch (AA->alias(A, B)) {
case NoAlias:
Expand Down Expand Up @@ -160,8 +156,7 @@ bool ProvenanceAnalysis::relatedCheck(const Value *A, const Value *B,
return true;
}

bool ProvenanceAnalysis::related(const Value *A, const Value *B,
const DataLayout &DL) {
bool ProvenanceAnalysis::related(const Value *A, const Value *B) {
A = GetUnderlyingObjCPtrCached(A, UnderlyingObjCPtrCache);
B = GetUnderlyingObjCPtrCached(B, UnderlyingObjCPtrCache);

Expand All @@ -178,7 +173,7 @@ bool ProvenanceAnalysis::related(const Value *A, const Value *B,
if (!Pair.second)
return Pair.first->second;

bool Result = relatedCheck(A, B, DL);
bool Result = relatedCheck(A, B);
CachedResults[ValuePairTy(A, B)] = Result;
return Result;
}
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.h
Expand Up @@ -58,7 +58,7 @@ class ProvenanceAnalysis {

DenseMap<const Value *, WeakTrackingVH> UnderlyingObjCPtrCache;

bool relatedCheck(const Value *A, const Value *B, const DataLayout &DL);
bool relatedCheck(const Value *A, const Value *B);
bool relatedSelect(const SelectInst *A, const Value *B);
bool relatedPHI(const PHINode *A, const Value *B);

Expand All @@ -71,7 +71,7 @@ class ProvenanceAnalysis {

AAResults *getAA() const { return AA; }

bool related(const Value *A, const Value *B, const DataLayout &DL);
bool related(const Value *A, const Value *B);

void clear() {
CachedResults.clear();
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Transforms/ObjCARC/ProvenanceAnalysisEvaluator.cpp
Expand Up @@ -66,7 +66,6 @@ bool PAEval::runOnFunction(Function &F) {

ProvenanceAnalysis PA;
PA.setAA(&getAnalysis<AAResultsWrapperPass>().getAAResults());
const DataLayout &DL = F.getParent()->getDataLayout();

for (Value *V1 : Values) {
StringRef NameV1 = getName(V1);
Expand All @@ -75,7 +74,7 @@ bool PAEval::runOnFunction(Function &F) {
if (NameV1 >= NameV2)
continue;
errs() << NameV1 << " and " << NameV2;
if (PA.related(V1, V2, DL))
if (PA.related(V1, V2))
errs() << " are related.\n";
else
errs() << " are not related.\n";
Expand Down

0 comments on commit b0f1d7d

Please sign in to comment.