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

Mircea Trofin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 29 15:41:24 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG3ab319b29559: [llvm][NFC] Use CallBase explicitly instead of Instruction in FunctionComparator (authored by mtrofin).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79098/new/

https://reviews.llvm.org/D79098

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


Index: llvm/lib/Transforms/Utils/FunctionComparator.cpp
===================================================================
--- llvm/lib/Transforms/Utils/FunctionComparator.cpp
+++ llvm/lib/Transforms/Utils/FunctionComparator.cpp
@@ -171,21 +171,17 @@
   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 @@
       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(),
Index: llvm/include/llvm/Transforms/Utils/FunctionComparator.h
===================================================================
--- llvm/include/llvm/Transforms/Utils/FunctionComparator.h
+++ llvm/include/llvm/Transforms/Utils/FunctionComparator.h
@@ -332,7 +332,7 @@
   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,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79098.261070.patch
Type: text/x-patch
Size: 2582 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200429/617fb1fc/attachment.bin>


More information about the llvm-commits mailing list