[llvm] [NFC][LLVM][IR] Adopt vadiadic `isa<>` (PR #137001)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 23 08:11:32 PDT 2025


https://github.com/jurahul created https://github.com/llvm/llvm-project/pull/137001

- Adopt variadic `isa<>` in all files except Verifier.cpp

>From f7d7b5e8b90be6ea359b187cae44b726a6cd495f Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Wed, 23 Apr 2025 08:08:50 -0700
Subject: [PATCH] [NFC][LLVM][IR] Adopt vadiadic `isa<>`

- Adopt variadic `isa<>` in all files except Verifier.cpp
---
 .../include/llvm/IR/DebugProgramInstruction.h |  3 +-
 llvm/include/llvm/IR/InstVisitor.h            |  2 +-
 llvm/include/llvm/IR/Instructions.h           | 12 +++-----
 llvm/include/llvm/IR/IntrinsicInst.h          |  4 +--
 llvm/include/llvm/IR/Operator.h               |  2 +-
 llvm/include/llvm/IR/User.h                   |  4 +--
 llvm/include/llvm/IR/Value.h                  |  5 ++--
 llvm/lib/IR/AsmWriter.cpp                     | 19 ++++++------
 llvm/lib/IR/BasicBlock.cpp                    |  9 +++---
 llvm/lib/IR/ConstantFold.cpp                  |  4 +--
 llvm/lib/IR/Constants.cpp                     | 22 +++++++-------
 llvm/lib/IR/Core.cpp                          |  4 +--
 llvm/lib/IR/DebugInfoMetadata.cpp             | 29 +++++++------------
 llvm/lib/IR/DiagnosticInfo.cpp                |  2 +-
 llvm/lib/IR/Dominators.cpp                    |  6 ++--
 llvm/lib/IR/Globals.cpp                       |  2 +-
 llvm/lib/IR/Instruction.cpp                   |  2 +-
 llvm/lib/IR/Instructions.cpp                  |  6 ++--
 .../IR/MemoryModelRelaxationAnnotations.cpp   |  5 ++--
 llvm/lib/IR/Metadata.cpp                      | 11 ++++---
 llvm/lib/IR/ReplaceConstant.cpp               |  4 +--
 llvm/lib/IR/SafepointIRVerifier.cpp           |  2 +-
 llvm/lib/IR/TypeFinder.cpp                    |  2 +-
 llvm/lib/IR/User.cpp                          |  2 +-
 24 files changed, 73 insertions(+), 90 deletions(-)

diff --git a/llvm/include/llvm/IR/DebugProgramInstruction.h b/llvm/include/llvm/IR/DebugProgramInstruction.h
index 37db7894d173d..e62c18a138acd 100644
--- a/llvm/include/llvm/IR/DebugProgramInstruction.h
+++ b/llvm/include/llvm/IR/DebugProgramInstruction.h
@@ -467,8 +467,7 @@ class DbgVariableRecord : public DbgRecord, protected DebugValueUser {
   /// replaceVariableLocationOp and addVariableLocationOps should be used where
   /// possible to avoid creating invalid state.
   void setRawLocation(Metadata *NewLocation) {
-    assert((isa<ValueAsMetadata>(NewLocation) || isa<DIArgList>(NewLocation) ||
-            isa<MDNode>(NewLocation)) &&
+    assert((isa<ValueAsMetadata, DIArgList, MDNode>(NewLocation)) &&
            "Location for a DbgVariableRecord must be either ValueAsMetadata or "
            "DIArgList");
     resetDebugValue(0, NewLocation);
diff --git a/llvm/include/llvm/IR/InstVisitor.h b/llvm/include/llvm/IR/InstVisitor.h
index 5fc6fbfd0f28e..84300a1a02000 100644
--- a/llvm/include/llvm/IR/InstVisitor.h
+++ b/llvm/include/llvm/IR/InstVisitor.h
@@ -268,7 +268,7 @@ class InstVisitor {
   // The next level delegation for `CallBase` is slightly more complex in order
   // to support visiting cases where the call is also a terminator.
   RetTy visitCallBase(CallBase &I) {
-    if (isa<InvokeInst>(I) || isa<CallBrInst>(I))
+    if (isa<InvokeInst, CallBrInst>(I))
       return static_cast<SubClass *>(this)->visitTerminator(I);
 
     DELEGATE(Instruction);
diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h
index 95f0ef875fc07..af5dfd72bbc40 100644
--- a/llvm/include/llvm/IR/Instructions.h
+++ b/llvm/include/llvm/IR/Instructions.h
@@ -5023,8 +5023,7 @@ inline Value *getPointerOperand(Value *V) {
 
 /// A helper function that returns the alignment of load or store instruction.
 inline Align getLoadStoreAlignment(const Value *I) {
-  assert((isa<LoadInst>(I) || isa<StoreInst>(I)) &&
-         "Expected Load or Store instruction");
+  assert((isa<LoadInst, StoreInst>(I)) && "Expected Load or Store instruction");
   if (auto *LI = dyn_cast<LoadInst>(I))
     return LI->getAlign();
   return cast<StoreInst>(I)->getAlign();
@@ -5032,8 +5031,7 @@ inline Align getLoadStoreAlignment(const Value *I) {
 
 /// A helper function that set the alignment of load or store instruction.
 inline void setLoadStoreAlignment(Value *I, Align NewAlign) {
-  assert((isa<LoadInst>(I) || isa<StoreInst>(I)) &&
-         "Expected Load or Store instruction");
+  assert((isa<LoadInst, StoreInst>(I)) && "Expected Load or Store instruction");
   if (auto *LI = dyn_cast<LoadInst>(I))
     LI->setAlignment(NewAlign);
   else
@@ -5043,8 +5041,7 @@ inline void setLoadStoreAlignment(Value *I, Align NewAlign) {
 /// A helper function that returns the address space of the pointer operand of
 /// load or store instruction.
 inline unsigned getLoadStoreAddressSpace(const Value *I) {
-  assert((isa<LoadInst>(I) || isa<StoreInst>(I)) &&
-         "Expected Load or Store instruction");
+  assert((isa<LoadInst, StoreInst>(I)) && "Expected Load or Store instruction");
   if (auto *LI = dyn_cast<LoadInst>(I))
     return LI->getPointerAddressSpace();
   return cast<StoreInst>(I)->getPointerAddressSpace();
@@ -5052,8 +5049,7 @@ inline unsigned getLoadStoreAddressSpace(const Value *I) {
 
 /// A helper function that returns the type of a load or store instruction.
 inline Type *getLoadStoreType(const Value *I) {
-  assert((isa<LoadInst>(I) || isa<StoreInst>(I)) &&
-         "Expected Load or Store instruction");
+  assert((isa<LoadInst, StoreInst>(I)) && "Expected Load or Store instruction");
   if (auto *LI = dyn_cast<LoadInst>(I))
     return LI->getType();
   return cast<StoreInst>(I)->getValueOperand()->getType();
diff --git a/llvm/include/llvm/IR/IntrinsicInst.h b/llvm/include/llvm/IR/IntrinsicInst.h
index 93750d6e3845e..cabb5fd297143 100644
--- a/llvm/include/llvm/IR/IntrinsicInst.h
+++ b/llvm/include/llvm/IR/IntrinsicInst.h
@@ -249,7 +249,7 @@ class RawLocationWrapper {
       : RawLocation(RawLocation) {
     // Allow ValueAsMetadata, empty MDTuple, DIArgList.
     assert(RawLocation && "unexpected null RawLocation");
-    assert(isa<ValueAsMetadata>(RawLocation) || isa<DIArgList>(RawLocation) ||
+    assert((isa<ValueAsMetadata, DIArgList>(RawLocation)) ||
            (isa<MDNode>(RawLocation) &&
             !cast<MDNode>(RawLocation)->getNumOperands()));
   }
@@ -1791,7 +1791,7 @@ class GCProjectionInst : public IntrinsicInst {
   bool isTiedToInvoke() const {
     const Value *Token = getArgOperand(0);
 
-    return isa<LandingPadInst>(Token) || isa<InvokeInst>(Token);
+    return isa<LandingPadInst, InvokeInst>(Token);
   }
 
   /// The statepoint with which this gc.relocate is associated.
diff --git a/llvm/include/llvm/IR/Operator.h b/llvm/include/llvm/IR/Operator.h
index 4d77860be994e..e15c4bfabfbfa 100644
--- a/llvm/include/llvm/IR/Operator.h
+++ b/llvm/include/llvm/IR/Operator.h
@@ -58,7 +58,7 @@ class Operator : public User {
   static bool classof(const Instruction *) { return true; }
   static bool classof(const ConstantExpr *) { return true; }
   static bool classof(const Value *V) {
-    return isa<Instruction>(V) || isa<ConstantExpr>(V);
+    return isa<Instruction, ConstantExpr>(V);
   }
 
   /// Return true if this operator has flags which may cause this operator
diff --git a/llvm/include/llvm/IR/User.h b/llvm/include/llvm/IR/User.h
index 39e1314bd8130..53a6a6d3c3bb2 100644
--- a/llvm/include/llvm/IR/User.h
+++ b/llvm/include/llvm/IR/User.h
@@ -354,9 +354,7 @@ class User : public Value {
   bool replaceUsesOfWith(Value *From, Value *To);
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
-  static bool classof(const Value *V) {
-    return isa<Instruction>(V) || isa<Constant>(V);
-  }
+  static bool classof(const Value *V) { return isa<Instruction, Constant>(V); }
 };
 
 // Either Use objects, or a Use pointer can be prepended to User.
diff --git a/llvm/include/llvm/IR/Value.h b/llvm/include/llvm/IR/Value.h
index cfed12e2f5f8d..944dd044dcde8 100644
--- a/llvm/include/llvm/IR/Value.h
+++ b/llvm/include/llvm/IR/Value.h
@@ -1046,14 +1046,13 @@ template <> struct isa_impl<GlobalIFunc, Value> {
 
 template <> struct isa_impl<GlobalValue, Value> {
   static inline bool doit(const Value &Val) {
-    return isa<GlobalObject>(Val) || isa<GlobalAlias>(Val);
+    return isa<GlobalObject, GlobalAlias>(Val);
   }
 };
 
 template <> struct isa_impl<GlobalObject, Value> {
   static inline bool doit(const Value &Val) {
-    return isa<GlobalVariable>(Val) || isa<Function>(Val) ||
-           isa<GlobalIFunc>(Val);
+    return isa<GlobalVariable, Function, GlobalIFunc>(Val);
   }
 };
 
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index ac8aa0d35ea30..7d7b419878898 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -141,7 +141,7 @@ static OrderMap orderModule(const Module *M) {
   OrderMap OM;
 
   auto orderConstantValue = [&OM](const Value *V) {
-    if (isa<Constant>(V) || isa<InlineAsm>(V))
+    if (isa<Constant, InlineAsm>(V))
       orderValue(V, OM);
   };
 
@@ -1625,7 +1625,7 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV,
     return;
   }
 
-  if (isa<ConstantAggregateZero>(CV) || isa<ConstantTargetNone>(CV)) {
+  if (isa<ConstantAggregateZero, ConstantTargetNone>(CV)) {
     Out << "zeroinitializer";
     return;
   }
@@ -1741,7 +1741,7 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV,
     return;
   }
 
-  if (isa<ConstantVector>(CV) || isa<ConstantDataVector>(CV)) {
+  if (isa<ConstantVector, ConstantDataVector>(CV)) {
     auto *CVVTy = cast<FixedVectorType>(CV->getType());
     Type *ETy = CVVTy->getElementType();
 
@@ -1751,7 +1751,7 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV,
     // TODO: Remove this block when the UseConstant{Int,FP}ForFixedLengthSplat
     // options are removed.
     if (auto *SplatVal = CV->getSplatValue()) {
-      if (isa<ConstantInt>(SplatVal) || isa<ConstantFP>(SplatVal)) {
+      if (isa<ConstantInt, ConstantFP>(SplatVal)) {
         Out << "splat (";
         WriterCtx.TypePrinter->print(ETy, Out);
         Out << ' ';
@@ -1803,7 +1803,7 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV,
     // options are removed.
     if (CE->getOpcode() == Instruction::ShuffleVector) {
       if (auto *SplatVal = CE->getSplatValue()) {
-        if (isa<ConstantInt>(SplatVal) || isa<ConstantFP>(SplatVal)) {
+        if (isa<ConstantInt, ConstantFP>(SplatVal)) {
           Out << "splat (";
           WriterCtx.TypePrinter->print(SplatVal->getType(), Out);
           Out << ' ';
@@ -4760,9 +4760,8 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
 
     // Select, Store, ShuffleVector, CmpXchg and AtomicRMW always print all
     // types.
-    if (isa<SelectInst>(I) || isa<StoreInst>(I) || isa<ShuffleVectorInst>(I) ||
-        isa<ReturnInst>(I) || isa<AtomicCmpXchgInst>(I) ||
-        isa<AtomicRMWInst>(I)) {
+    if (isa<SelectInst, StoreInst, ShuffleVectorInst, ReturnInst,
+            AtomicCmpXchgInst, AtomicRMWInst>(I)) {
       PrintAllTypes = true;
     } else {
       for (unsigned i = 1, E = I.getNumOperands(); i != E; ++i) {
@@ -5194,7 +5193,7 @@ void Value::print(raw_ostream &ROS, bool IsForDebug) const {
   bool ShouldInitializeAllMetadata = false;
   if (auto *I = dyn_cast<Instruction>(this))
     ShouldInitializeAllMetadata = isReferencingMDNode(*I);
-  else if (isa<Function>(this) || isa<MetadataAsValue>(this))
+  else if (isa<Function, MetadataAsValue>(this))
     ShouldInitializeAllMetadata = true;
 
   ModuleSlotTracker MST(getModuleFromVal(this), ShouldInitializeAllMetadata);
@@ -5240,7 +5239,7 @@ void Value::print(raw_ostream &ROS, ModuleSlotTracker &MST,
     OS << ' ';
     AsmWriterContext WriterCtx(&TypePrinter, MST.getMachine());
     WriteConstantInternal(OS, C, WriterCtx);
-  } else if (isa<InlineAsm>(this) || isa<Argument>(this)) {
+  } else if (isa<InlineAsm, Argument>(this)) {
     this->printAsOperand(OS, /* PrintType */ true, MST);
   } else {
     llvm_unreachable("Unknown value to print out!");
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index c632b1b2dc2ab..e4660058a05e4 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -362,7 +362,7 @@ const Instruction *BasicBlock::getFirstMayFaultInst() const {
   if (InstList.empty())
     return nullptr;
   for (const Instruction &I : *this)
-    if (isa<LoadInst>(I) || isa<StoreInst>(I) || isa<CallBase>(I))
+    if (isa<LoadInst, StoreInst, CallBase>(I))
       return &I;
   return nullptr;
 }
@@ -400,7 +400,7 @@ BasicBlock::const_iterator BasicBlock::getFirstNonPHIIt() const {
 BasicBlock::const_iterator
 BasicBlock::getFirstNonPHIOrDbg(bool SkipPseudoOp) const {
   for (const Instruction &I : *this) {
-    if (isa<PHINode>(I) || isa<DbgInfoIntrinsic>(I))
+    if (isa<PHINode, DbgInfoIntrinsic>(I))
       continue;
 
     if (SkipPseudoOp && isa<PseudoProbeInst>(I))
@@ -418,7 +418,7 @@ BasicBlock::getFirstNonPHIOrDbg(bool SkipPseudoOp) const {
 BasicBlock::const_iterator
 BasicBlock::getFirstNonPHIOrDbgOrLifetime(bool SkipPseudoOp) const {
   for (const Instruction &I : *this) {
-    if (isa<PHINode>(I) || isa<DbgInfoIntrinsic>(I))
+    if (isa<PHINode, DbgInfoIntrinsic>(I))
       continue;
 
     if (I.isLifetimeStartOrEnd())
@@ -461,8 +461,7 @@ BasicBlock::const_iterator BasicBlock::getFirstNonPHIOrDbgOrAlloca() const {
   if (isEntryBlock()) {
     const_iterator End = end();
     while (InsertPt != End &&
-           (isa<AllocaInst>(*InsertPt) || isa<DbgInfoIntrinsic>(*InsertPt) ||
-            isa<PseudoProbeInst>(*InsertPt))) {
+           isa<AllocaInst, DbgInfoIntrinsic, PseudoProbeInst>(*InsertPt)) {
       if (const AllocaInst *AI = dyn_cast<AllocaInst>(&*InsertPt)) {
         if (!AI->isStaticAlloca())
           break;
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index 7e5fda229b858..1afc908c8ff14 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -321,8 +321,8 @@ Constant *llvm::ConstantFoldSelectInstruction(Constant *Cond,
     if (isa<ConstantExpr>(C))
       return false;
 
-    if (isa<ConstantInt>(C) || isa<GlobalVariable>(C) || isa<ConstantFP>(C) ||
-        isa<ConstantPointerNull>(C) || isa<Function>(C))
+    if (isa<ConstantInt, GlobalVariable, ConstantFP, ConstantPointerNull,
+            Function>(C))
       return true;
 
     if (C->getType()->isVectorTy())
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index fb659450bfeeb..2bc6c8cd276db 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -100,8 +100,8 @@ bool Constant::isNullValue() const {
 
   // constant zero is zero for aggregates, cpnull is null for pointers, none for
   // tokens.
-  return isa<ConstantAggregateZero>(this) || isa<ConstantPointerNull>(this) ||
-         isa<ConstantTokenNone>(this) || isa<ConstantTargetNone>(this);
+  return isa<ConstantAggregateZero, ConstantPointerNull, ConstantTokenNone,
+             ConstantTargetNone>(this);
 }
 
 bool Constant::isAllOnesValue() const {
@@ -358,7 +358,7 @@ bool Constant::containsUndefElement() const {
 }
 
 bool Constant::containsConstantExpression() const {
-  if (isa<ConstantInt>(this) || isa<ConstantFP>(this))
+  if (isa<ConstantInt, ConstantFP>(this))
     return false;
 
   if (auto *VTy = dyn_cast<FixedVectorType>(getType())) {
@@ -845,7 +845,7 @@ bool Constant::isManifestConstant() const {
     return false;
   if (isa<ConstantData>(this))
     return true;
-  if (isa<ConstantAggregate>(this) || isa<ConstantExpr>(this)) {
+  if (isa<ConstantAggregate, ConstantExpr>(this)) {
     for (const Value *Op : operand_values())
       if (!cast<Constant>(Op)->isManifestConstant())
         return false;
@@ -1142,13 +1142,13 @@ Constant *ConstantAggregateZero::getStructElement(unsigned Elt) const {
 }
 
 Constant *ConstantAggregateZero::getElementValue(Constant *C) const {
-  if (isa<ArrayType>(getType()) || isa<VectorType>(getType()))
+  if (isa<ArrayType, VectorType>(getType()))
     return getSequentialElement();
   return getStructElement(cast<ConstantInt>(C)->getZExtValue());
 }
 
 Constant *ConstantAggregateZero::getElementValue(unsigned Idx) const {
-  if (isa<ArrayType>(getType()) || isa<VectorType>(getType()))
+  if (isa<ArrayType, VectorType>(getType()))
     return getSequentialElement();
   return getStructElement(Idx);
 }
@@ -1177,13 +1177,13 @@ UndefValue *UndefValue::getStructElement(unsigned Elt) const {
 }
 
 UndefValue *UndefValue::getElementValue(Constant *C) const {
-  if (isa<ArrayType>(getType()) || isa<VectorType>(getType()))
+  if (isa<ArrayType, VectorType>(getType()))
     return getSequentialElement();
   return getStructElement(cast<ConstantInt>(C)->getZExtValue());
 }
 
 UndefValue *UndefValue::getElementValue(unsigned Idx) const {
-  if (isa<ArrayType>(getType()) || isa<VectorType>(getType()))
+  if (isa<ArrayType, VectorType>(getType()))
     return getSequentialElement();
   return getStructElement(Idx);
 }
@@ -1212,13 +1212,13 @@ PoisonValue *PoisonValue::getStructElement(unsigned Elt) const {
 }
 
 PoisonValue *PoisonValue::getElementValue(Constant *C) const {
-  if (isa<ArrayType>(getType()) || isa<VectorType>(getType()))
+  if (isa<ArrayType, VectorType>(getType()))
     return getSequentialElement();
   return getStructElement(cast<ConstantInt>(C)->getZExtValue());
 }
 
 PoisonValue *PoisonValue::getElementValue(unsigned Idx) const {
-  if (isa<ArrayType>(getType()) || isa<VectorType>(getType()))
+  if (isa<ArrayType, VectorType>(getType()))
     return getSequentialElement();
   return getStructElement(Idx);
 }
@@ -1485,7 +1485,7 @@ Constant *ConstantVector::getSplat(ElementCount EC, Constant *V) {
 
     // If this splat is compatible with ConstantDataVector, use it instead of
     // ConstantVector.
-    if ((isa<ConstantFP>(V) || isa<ConstantInt>(V)) &&
+    if ((isa<ConstantFP, ConstantInt>(V)) &&
         ConstantDataSequential::isElementTypeCompatible(V->getType()))
       return ConstantDataVector::getSplat(EC.getKnownMinValue(), V);
 
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index f4b03e8cb8aa3..4e62b96d13776 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -1091,8 +1091,8 @@ LLVMValueRef LLVMGetMetadata(LLVMValueRef Inst, unsigned KindID) {
 // This undoes this canonicalization, reconstructing the MDNode.
 static MDNode *extractMDNode(MetadataAsValue *MAV) {
   Metadata *MD = MAV->getMetadata();
-  assert((isa<MDNode>(MD) || isa<ConstantAsMetadata>(MD)) &&
-      "Expected a metadata node or a canonicalized constant");
+  assert((isa<MDNode, ConstantAsMetadata>(MD)) &&
+         "Expected a metadata node or a canonicalized constant");
 
   if (MDNode *N = dyn_cast<MDNode>(MD))
     return N;
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp
index 4f1b9e836120e..959db9c295df6 100644
--- a/llvm/lib/IR/DebugInfoMetadata.cpp
+++ b/llvm/lib/IR/DebugInfoMetadata.cpp
@@ -476,8 +476,7 @@ DIScope *DIScope::getScope() const {
   if (auto *M = dyn_cast<DIModule>(this))
     return M->getScope();
 
-  assert((isa<DIFile>(this) || isa<DICompileUnit>(this)) &&
-         "Unhandled type of scope.");
+  assert((isa<DIFile, DICompileUnit>(this)) && "Unhandled type of scope.");
   return nullptr;
 }
 
@@ -492,8 +491,7 @@ StringRef DIScope::getName() const {
     return CB->getName();
   if (auto *M = dyn_cast<DIModule>(this))
     return M->getName();
-  assert((isa<DILexicalBlockBase>(this) || isa<DIFile>(this) ||
-          isa<DICompileUnit>(this)) &&
+  assert((isa<DILexicalBlockBase, DIFile, DICompileUnit>(this)) &&
          "Unhandled type of scope.");
   return "";
 }
@@ -599,8 +597,7 @@ DISubrange::BoundType DISubrange::getCount() const {
   if (!CB)
     return BoundType();
 
-  assert((isa<ConstantAsMetadata>(CB) || isa<DIVariable>(CB) ||
-          isa<DIExpression>(CB)) &&
+  assert((isa<ConstantAsMetadata, DIVariable, DIExpression>(CB)) &&
          "Count must be signed constant or DIVariable or DIExpression");
 
   if (auto *MD = dyn_cast<ConstantAsMetadata>(CB))
@@ -620,8 +617,7 @@ DISubrange::BoundType DISubrange::getLowerBound() const {
   if (!LB)
     return BoundType();
 
-  assert((isa<ConstantAsMetadata>(LB) || isa<DIVariable>(LB) ||
-          isa<DIExpression>(LB)) &&
+  assert((isa<ConstantAsMetadata, DIVariable, DIExpression>(LB)) &&
          "LowerBound must be signed constant or DIVariable or DIExpression");
 
   if (auto *MD = dyn_cast<ConstantAsMetadata>(LB))
@@ -641,8 +637,7 @@ DISubrange::BoundType DISubrange::getUpperBound() const {
   if (!UB)
     return BoundType();
 
-  assert((isa<ConstantAsMetadata>(UB) || isa<DIVariable>(UB) ||
-          isa<DIExpression>(UB)) &&
+  assert((isa<ConstantAsMetadata, DIVariable, DIExpression>(UB)) &&
          "UpperBound must be signed constant or DIVariable or DIExpression");
 
   if (auto *MD = dyn_cast<ConstantAsMetadata>(UB))
@@ -662,8 +657,7 @@ DISubrange::BoundType DISubrange::getStride() const {
   if (!ST)
     return BoundType();
 
-  assert((isa<ConstantAsMetadata>(ST) || isa<DIVariable>(ST) ||
-          isa<DIExpression>(ST)) &&
+  assert((isa<ConstantAsMetadata, DIVariable, DIExpression>(ST)) &&
          "Stride must be signed constant or DIVariable or DIExpression");
 
   if (auto *MD = dyn_cast<ConstantAsMetadata>(ST))
@@ -697,7 +691,7 @@ DIGenericSubrange::BoundType DIGenericSubrange::getCount() const {
   if (!CB)
     return BoundType();
 
-  assert((isa<DIVariable>(CB) || isa<DIExpression>(CB)) &&
+  assert((isa<DIVariable, DIExpression>(CB)) &&
          "Count must be signed constant or DIVariable or DIExpression");
 
   if (auto *MD = dyn_cast<DIVariable>(CB))
@@ -714,7 +708,7 @@ DIGenericSubrange::BoundType DIGenericSubrange::getLowerBound() const {
   if (!LB)
     return BoundType();
 
-  assert((isa<DIVariable>(LB) || isa<DIExpression>(LB)) &&
+  assert((isa<DIVariable, DIExpression>(LB)) &&
          "LowerBound must be signed constant or DIVariable or DIExpression");
 
   if (auto *MD = dyn_cast<DIVariable>(LB))
@@ -731,7 +725,7 @@ DIGenericSubrange::BoundType DIGenericSubrange::getUpperBound() const {
   if (!UB)
     return BoundType();
 
-  assert((isa<DIVariable>(UB) || isa<DIExpression>(UB)) &&
+  assert((isa<DIVariable, DIExpression>(UB)) &&
          "UpperBound must be signed constant or DIVariable or DIExpression");
 
   if (auto *MD = dyn_cast<DIVariable>(UB))
@@ -748,7 +742,7 @@ DIGenericSubrange::BoundType DIGenericSubrange::getStride() const {
   if (!ST)
     return BoundType();
 
-  assert((isa<DIVariable>(ST) || isa<DIExpression>(ST)) &&
+  assert((isa<DIVariable, DIExpression>(ST)) &&
          "Stride must be signed constant or DIVariable or DIExpression");
 
   if (auto *MD = dyn_cast<DIVariable>(ST))
@@ -787,8 +781,7 @@ DISubrangeType::convertRawToBound(Metadata *IN) const {
   if (!IN)
     return BoundType();
 
-  assert(isa<ConstantAsMetadata>(IN) || isa<DIVariable>(IN) ||
-         isa<DIExpression>(IN));
+  assert((isa<ConstantAsMetadata, DIVariable, DIExpression>(IN)));
 
   if (auto *MD = dyn_cast<ConstantAsMetadata>(IN))
     return BoundType(cast<ConstantInt>(MD->getValue()));
diff --git a/llvm/lib/IR/DiagnosticInfo.cpp b/llvm/lib/IR/DiagnosticInfo.cpp
index 4315f63cce4f8..034ee4b8d189c 100644
--- a/llvm/lib/IR/DiagnosticInfo.cpp
+++ b/llvm/lib/IR/DiagnosticInfo.cpp
@@ -206,7 +206,7 @@ DiagnosticInfoOptimizationBase::Argument::Argument(StringRef Key,
 
   // Only include names that correspond to user variables.  FIXME: We should use
   // debug info if available to get the name of the user variable.
-  if (isa<llvm::Argument>(V) || isa<GlobalValue>(V))
+  if (isa<llvm::Argument, GlobalValue>(V))
     Val = std::string(GlobalValue::dropLLVMManglingEscape(V->getName()));
   else if (isa<Constant>(V)) {
     raw_string_ostream OS(Val);
diff --git a/llvm/lib/IR/Dominators.cpp b/llvm/lib/IR/Dominators.cpp
index cc51b4905a628..d02dad4541a5f 100644
--- a/llvm/lib/IR/Dominators.cpp
+++ b/llvm/lib/IR/Dominators.cpp
@@ -136,7 +136,7 @@ bool DominatorTree::dominates(const Value *DefV,
                               const Instruction *User) const {
   const Instruction *Def = dyn_cast<Instruction>(DefV);
   if (!Def) {
-    assert((isa<Argument>(DefV) || isa<Constant>(DefV)) &&
+    assert((isa<Argument, Constant>(DefV)) &&
            "Should be called with an instruction, argument or constant");
     return true; // Arguments and constants dominate everything.
   }
@@ -160,7 +160,7 @@ bool DominatorTree::dominates(const Value *DefV,
   // dominates every instruction in UseBB.
   // A PHI is dominated only if the instruction dominates every possible use in
   // the UseBB.
-  if (isa<InvokeInst>(Def) || isa<CallBrInst>(Def) || isa<PHINode>(User))
+  if (isa<InvokeInst, CallBrInst>(Def) || isa<PHINode>(User))
     return dominates(Def, UseBB);
 
   if (DefBB != UseBB)
@@ -268,7 +268,7 @@ bool DominatorTree::dominates(const BasicBlockEdge &BBE, const Use &U) const {
 bool DominatorTree::dominates(const Value *DefV, const Use &U) const {
   const Instruction *Def = dyn_cast<Instruction>(DefV);
   if (!Def) {
-    assert((isa<Argument>(DefV) || isa<Constant>(DefV)) &&
+    assert((isa<Argument, Constant>(DefV)) &&
            "Should be called with an instruction, argument or constant");
     return true; // Arguments and constants dominate everything.
   }
diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 401f8ac58bce8..d62092f01cfbd 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -322,7 +322,7 @@ bool GlobalValue::isDeclaration() const {
     return F->empty() && !F->isMaterializable();
 
   // Aliases and ifuncs are always definitions.
-  assert(isa<GlobalAlias>(this) || isa<GlobalIFunc>(this));
+  assert((isa<GlobalAlias, GlobalIFunc>(this)));
   return false;
 }
 
diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index 4eadecb54feb5..b82d9067bdc2e 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -1219,7 +1219,7 @@ bool Instruction::isLaunderOrStripInvariantGroup() const {
 }
 
 bool Instruction::isDebugOrPseudoInst() const {
-  return isa<DbgInfoIntrinsic>(this) || isa<PseudoProbeInst>(this);
+  return isa<DbgInfoIntrinsic, PseudoProbeInst>(this);
 }
 
 const Instruction *
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 3ae88bd54d719..287df5d3ed2c5 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -333,7 +333,7 @@ unsigned CallBase::getNumSubclassExtraOperandsDynamic() const {
 
 bool CallBase::isIndirectCall() const {
   const Value *V = getCalledOperand();
-  if (isa<Function>(V) || isa<Constant>(V))
+  if (isa<Function, Constant>(V))
     return false;
   return !isInlineAsm();
 }
@@ -1809,7 +1809,7 @@ bool ShuffleVectorInst::isValidOperands(const Value *V1, const Value *V2,
     return false;
 
   // Check to see if Mask is valid.
-  if (isa<UndefValue>(Mask) || isa<ConstantAggregateZero>(Mask))
+  if (isa<UndefValue, ConstantAggregateZero>(Mask))
     return true;
 
   // NOTE: Through vector ConstantInt we have the potential to support more
@@ -1857,7 +1857,7 @@ void ShuffleVectorInst::getShuffleMask(const Constant *Mask,
   Result.reserve(EC.getKnownMinValue());
 
   if (EC.isScalable()) {
-    assert((isa<ConstantAggregateZero>(Mask) || isa<UndefValue>(Mask)) &&
+    assert((isa<ConstantAggregateZero, UndefValue>(Mask)) &&
            "Scalable vector shuffle mask must be undef or zeroinitializer");
     int MaskVal = isa<UndefValue>(Mask) ? -1 : 0;
     for (unsigned I = 0; I < EC.getKnownMinValue(); ++I)
diff --git a/llvm/lib/IR/MemoryModelRelaxationAnnotations.cpp b/llvm/lib/IR/MemoryModelRelaxationAnnotations.cpp
index 819cad3366787..4d757726c6c4e 100644
--- a/llvm/lib/IR/MemoryModelRelaxationAnnotations.cpp
+++ b/llvm/lib/IR/MemoryModelRelaxationAnnotations.cpp
@@ -164,6 +164,7 @@ static bool isReadWriteMemCall(const Instruction &I) {
 }
 
 bool llvm::canInstructionHaveMMRAs(const Instruction &I) {
-  return isa<LoadInst>(I) || isa<StoreInst>(I) || isa<AtomicCmpXchgInst>(I) ||
-         isa<AtomicRMWInst>(I) || isa<FenceInst>(I) || isReadWriteMemCall(I);
+  return isa<LoadInst, StoreInst, AtomicCmpXchgInst, AtomicRMWInst, FenceInst>(
+             I) ||
+         isReadWriteMemCall(I);
 }
diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index 8e78cd9cc573a..7934b222cbb15 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -479,7 +479,7 @@ ReplaceableMetadataImpl *ReplaceableMetadataImpl::getIfExists(Metadata &MD) {
 bool ReplaceableMetadataImpl::isReplaceable(const Metadata &MD) {
   if (auto *N = dyn_cast<MDNode>(&MD))
     return !N->isResolved() || N->isAlwaysReplaceable();
-  return isa<ValueAsMetadata>(&MD) || isa<DIArgList>(&MD);
+  return isa<ValueAsMetadata, DIArgList>(MD);
 }
 
 static DISubprogram *getLocalFunctionMetadata(Value *V) {
@@ -505,7 +505,7 @@ ValueAsMetadata *ValueAsMetadata::get(Value *V) {
   auto &Context = V->getContext();
   auto *&Entry = Context.pImpl->ValuesAsMetadata[V];
   if (!Entry) {
-    assert((isa<Constant>(V) || isa<Argument>(V) || isa<Instruction>(V)) &&
+    assert((isa<Constant, Argument, Instruction>(V)) &&
            "Expected constant or function-local value");
     assert(!V->IsUsedByMD && "Expected this to be the only metadata use");
     V->IsUsedByMD = true;
@@ -1550,7 +1550,7 @@ void Value::getAllMetadata(
 }
 
 void Value::setMetadata(unsigned KindID, MDNode *Node) {
-  assert(isa<Instruction>(this) || isa<GlobalObject>(this));
+  assert((isa<Instruction, GlobalObject>(this)));
 
   // Handle the case when we're adding/updating metadata on a value.
   if (Node) {
@@ -1584,9 +1584,8 @@ void Value::setMetadata(StringRef Kind, MDNode *Node) {
 }
 
 void Value::addMetadata(unsigned KindID, MDNode &MD) {
-  assert(isa<Instruction>(this) || isa<GlobalObject>(this));
-  if (!HasMetadata)
-    HasMetadata = true;
+  assert((isa<Instruction, GlobalObject>(this)));
+  HasMetadata = true;
   getContext().pImpl->ValueMetadata[this].insert(KindID, MD);
 }
 
diff --git a/llvm/lib/IR/ReplaceConstant.cpp b/llvm/lib/IR/ReplaceConstant.cpp
index 962368f061851..4d45ff54a091d 100644
--- a/llvm/lib/IR/ReplaceConstant.cpp
+++ b/llvm/lib/IR/ReplaceConstant.cpp
@@ -19,7 +19,7 @@
 namespace llvm {
 
 static bool isExpandableUser(User *U) {
-  return isa<ConstantExpr>(U) || isa<ConstantAggregate>(U);
+  return isa<ConstantExpr, ConstantAggregate>(U);
 }
 
 static SmallVector<Instruction *, 4> expandUser(BasicBlock::iterator InsertPt,
@@ -29,7 +29,7 @@ static SmallVector<Instruction *, 4> expandUser(BasicBlock::iterator InsertPt,
     Instruction *ConstInst = CE->getAsInstruction();
     ConstInst->insertBefore(*InsertPt->getParent(), InsertPt);
     NewInsts.push_back(ConstInst);
-  } else if (isa<ConstantStruct>(C) || isa<ConstantArray>(C)) {
+  } else if (isa<ConstantStruct, ConstantArray>(C)) {
     Value *V = PoisonValue::get(C->getType());
     for (auto [Idx, Op] : enumerate(C->operands())) {
       V = InsertValueInst::Create(V, Op, Idx, "", InsertPt);
diff --git a/llvm/lib/IR/SafepointIRVerifier.cpp b/llvm/lib/IR/SafepointIRVerifier.cpp
index 09eab3d19b4d0..f9d63d751dffa 100644
--- a/llvm/lib/IR/SafepointIRVerifier.cpp
+++ b/llvm/lib/IR/SafepointIRVerifier.cpp
@@ -696,7 +696,7 @@ bool GCPtrTracker::removeValidUnrelocatedDefs(const BasicBlock *BB,
             ValidUnrelocatedPointerDef = true;
         }
       }
-    } else if ((isa<GetElementPtrInst>(I) || isa<BitCastInst>(I)) &&
+    } else if (isa<GetElementPtrInst, BitCastInst>(I) &&
                containsGCPtrType(I.getType())) {
       // GEP/bitcast of unrelocated pointer is legal by itself but this def
       // shouldn't appear in any AvailableSet.
diff --git a/llvm/lib/IR/TypeFinder.cpp b/llvm/lib/IR/TypeFinder.cpp
index 963f4b4806e1f..132d458fcb839 100644
--- a/llvm/lib/IR/TypeFinder.cpp
+++ b/llvm/lib/IR/TypeFinder.cpp
@@ -142,7 +142,7 @@ void TypeFinder::incorporateType(Type *Ty) {
 
 /// incorporateValue - This method is used to walk operand lists finding types
 /// hiding in constant expressions and other operands that won't be walked in
-/// other ways.  GlobalValues, basic blocks, instructions, and inst operands are
+/// other ways. GlobalValues, basic blocks, instructions, and inst operands are
 /// all explicitly enumerated.
 void TypeFinder::incorporateValue(const Value *V) {
   if (const auto *M = dyn_cast<MetadataAsValue>(V)) {
diff --git a/llvm/lib/IR/User.cpp b/llvm/lib/IR/User.cpp
index ab44cb4b8a3f7..7d4718274516b 100644
--- a/llvm/lib/IR/User.cpp
+++ b/llvm/lib/IR/User.cpp
@@ -22,7 +22,7 @@ bool User::replaceUsesOfWith(Value *From, Value *To) {
   bool Changed = false;
   if (From == To) return Changed;   // Duh what?
 
-  assert((!isa<Constant>(this) || isa<GlobalValue>(this)) &&
+  assert((!isa<Constant, GlobalValue>(this)) &&
          "Cannot call User::replaceUsesOfWith on a constant!");
 
   for (unsigned i = 0, E = getNumOperands(); i != E; ++i)



More information about the llvm-commits mailing list