[llvm] 3ab319b - [llvm][NFC] Use CallBase explicitly instead of Instruction in FunctionComparator

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 29 15:40:18 PDT 2020


Author: Mircea Trofin
Date: 2020-04-29T15:37:46-07:00
New Revision: 3ab319b295598a17c3b65a654065d4963aba1e73

URL: https://github.com/llvm/llvm-project/commit/3ab319b295598a17c3b65a654065d4963aba1e73
DIFF: https://github.com/llvm/llvm-project/commit/3ab319b295598a17c3b65a654065d4963aba1e73.diff

LOG: [llvm][NFC] Use CallBase explicitly instead of Instruction in FunctionComparator

Reviewers: dblaikie, craig.topper

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79098

Added: 
    

Modified: 
    llvm/include/llvm/Transforms/Utils/FunctionComparator.h
    llvm/lib/Transforms/Utils/FunctionComparator.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Transforms/Utils/FunctionComparator.h b/llvm/include/llvm/Transforms/Utils/FunctionComparator.h
index 4e2571b1d0b6..e808a50b320f 100644
--- a/llvm/include/llvm/Transforms/Utils/FunctionComparator.h
+++ b/llvm/include/llvm/Transforms/Utils/FunctionComparator.h
@@ -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,

diff  --git a/llvm/lib/Transforms/Utils/FunctionComparator.cpp b/llvm/lib/Transforms/Utils/FunctionComparator.cpp
index 655ba9350b02..8a9ff13329fb 100644
--- a/llvm/lib/Transforms/Utils/FunctionComparator.cpp
+++ b/llvm/lib/Transforms/Utils/FunctionComparator.cpp
@@ -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;
@@ -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(),


        


More information about the llvm-commits mailing list