[polly] r340701 - [IR] Replace `isa<TerminatorInst>` with `isTerminator()`.

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 26 02:51:23 PDT 2018


Author: chandlerc
Date: Sun Aug 26 02:51:22 2018
New Revision: 340701

URL: http://llvm.org/viewvc/llvm-project?rev=340701&view=rev
Log:
[IR] Replace `isa<TerminatorInst>` with `isTerminator()`.

This is a bit awkward in a handful of places where we didn't even have
an instruction and now we have to see if we can build one. But on the
whole, this seems like a win and at worst a reasonable cost for removing
`TerminatorInst`.

All of this is part of the removal of `TerminatorInst` from the
`Instruction` type hierarchy.

Modified:
    polly/trunk/lib/Analysis/ScopBuilder.cpp
    polly/trunk/lib/Analysis/ScopDetection.cpp
    polly/trunk/lib/Support/VirtualInstruction.cpp

Modified: polly/trunk/lib/Analysis/ScopBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopBuilder.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopBuilder.cpp (original)
+++ polly/trunk/lib/Analysis/ScopBuilder.cpp Sun Aug 26 02:51:22 2018
@@ -685,7 +685,7 @@ void ScopBuilder::buildAccessFunctions()
 }
 
 bool ScopBuilder::shouldModelInst(Instruction *Inst, Loop *L) {
-  return !isa<TerminatorInst>(Inst) && !isIgnoredIntrinsic(Inst) &&
+  return !Inst->isTerminator() && !isIgnoredIntrinsic(Inst) &&
          !canSynthesize(Inst, *scop, &SE, L);
 }
 
@@ -1399,7 +1399,7 @@ static void verifyUses(Scop *S, LoopInfo
         continue;
 
       // Branch conditions are encoded in the statement domains.
-      if (isa<TerminatorInst>(&Inst) && Stmt->isBlockStmt())
+      if (Inst.isTerminator() && Stmt->isBlockStmt())
         continue;
 
       // Verify all uses.

Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetection.cpp Sun Aug 26 02:51:22 2018
@@ -1214,7 +1214,8 @@ bool ScopDetection::isValidInstruction(I
       auto *PHI = dyn_cast<PHINode>(OpInst);
       if (PHI) {
         for (User *U : PHI->users()) {
-          if (!isa<TerminatorInst>(U))
+          auto *UI = dyn_cast<Instruction>(U);
+          if (!UI || !UI->isTerminator())
             return false;
         }
       } else {

Modified: polly/trunk/lib/Support/VirtualInstruction.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Support/VirtualInstruction.cpp?rev=340701&r1=340700&r2=340701&view=diff
==============================================================================
--- polly/trunk/lib/Support/VirtualInstruction.cpp (original)
+++ polly/trunk/lib/Support/VirtualInstruction.cpp Sun Aug 26 02:51:22 2018
@@ -178,7 +178,7 @@ static bool isRoot(const Instruction *In
 
   // Terminator instructions (in region statements) are required for control
   // flow.
-  if (isa<TerminatorInst>(Inst))
+  if (Inst->isTerminator())
     return true;
 
   // Writes to memory must be honored.




More information about the llvm-commits mailing list