Skip to content

Commit

Permalink
[llvm][NFC] Use CallBase explicitly instead of Instruction in Functio…
Browse files Browse the repository at this point in the history
…nComparator

Reviewers: dblaikie, craig.topper

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79098
  • Loading branch information
mtrofin committed Apr 29, 2020
1 parent ffd5e12 commit 3ab319b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion llvm/include/llvm/Transforms/Utils/FunctionComparator.h
Expand Up @@ -332,7 +332,7 @@ class FunctionComparator {
int cmpInlineAsm(const InlineAsm *L, const InlineAsm *R) const;
int cmpAttrs(const AttributeList L, const AttributeList R) const;
int cmpRangeMetadata(const MDNode *L, const MDNode *R) const;
int cmpOperandBundlesSchema(const Instruction *L, const Instruction *R) const;
int cmpOperandBundlesSchema(const CallBase &LCS, const CallBase &RCS) const;

/// Compare two GEPs for equivalent pointer arithmetic.
/// Parts to be compared for each comparison stage,
Expand Down
20 changes: 8 additions & 12 deletions llvm/lib/Transforms/Utils/FunctionComparator.cpp
Expand Up @@ -171,21 +171,17 @@ int FunctionComparator::cmpRangeMetadata(const MDNode *L,
return 0;
}

// FIXME(CallSite): the parameters should be CallBase
int FunctionComparator::cmpOperandBundlesSchema(const Instruction *L,
const Instruction *R) const {
const CallBase *LCS = cast<CallBase>(L);
const CallBase *RCS = cast<CallBase>(R);

assert(LCS->getOpcode() == RCS->getOpcode() && "Can't compare otherwise!");
int FunctionComparator::cmpOperandBundlesSchema(const CallBase &LCS,
const CallBase &RCS) const {
assert(LCS.getOpcode() == RCS.getOpcode() && "Can't compare otherwise!");

if (int Res =
cmpNumbers(LCS->getNumOperandBundles(), RCS->getNumOperandBundles()))
cmpNumbers(LCS.getNumOperandBundles(), RCS.getNumOperandBundles()))
return Res;

for (unsigned i = 0, e = LCS->getNumOperandBundles(); i != e; ++i) {
auto OBL = LCS->getOperandBundleAt(i);
auto OBR = RCS->getOperandBundleAt(i);
for (unsigned I = 0, E = LCS.getNumOperandBundles(); I != E; ++I) {
auto OBL = LCS.getOperandBundleAt(I);
auto OBR = RCS.getOperandBundleAt(I);

if (int Res = OBL.getTagName().compare(OBR.getTagName()))
return Res;
Expand Down Expand Up @@ -592,7 +588,7 @@ int FunctionComparator::cmpOperations(const Instruction *L,
return Res;
if (int Res = cmpAttrs(CBL->getAttributes(), CBR->getAttributes()))
return Res;
if (int Res = cmpOperandBundlesSchema(L, R))
if (int Res = cmpOperandBundlesSchema(*CBL, *CBR))
return Res;
if (const CallInst *CI = dyn_cast<CallInst>(L))
if (int Res = cmpNumbers(CI->getTailCallKind(),
Expand Down

0 comments on commit 3ab319b

Please sign in to comment.