From 844499013f21efe13b5f85ed8e543f06c4e41a61 Mon Sep 17 00:00:00 2001 From: Rahul Joshi 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 | 1 + 24 files changed, 73 insertions(+), 89 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(NewLocation) || isa(NewLocation) || - isa(NewLocation)) && + assert((isa(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(I) || isa(I)) + if (isa(I)) return static_cast(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(I) || isa(I)) && - "Expected Load or Store instruction"); + assert((isa(I)) && "Expected Load or Store instruction"); if (auto *LI = dyn_cast(I)) return LI->getAlign(); return cast(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(I) || isa(I)) && - "Expected Load or Store instruction"); + assert((isa(I)) && "Expected Load or Store instruction"); if (auto *LI = dyn_cast(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(I) || isa(I)) && - "Expected Load or Store instruction"); + assert((isa(I)) && "Expected Load or Store instruction"); if (auto *LI = dyn_cast(I)) return LI->getPointerAddressSpace(); return cast(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(I) || isa(I)) && - "Expected Load or Store instruction"); + assert((isa(I)) && "Expected Load or Store instruction"); if (auto *LI = dyn_cast(I)) return LI->getType(); return cast(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(RawLocation) || isa(RawLocation) || + assert((isa(RawLocation)) || (isa(RawLocation) && !cast(RawLocation)->getNumOperands())); } @@ -1791,7 +1791,7 @@ class GCProjectionInst : public IntrinsicInst { bool isTiedToInvoke() const { const Value *Token = getArgOperand(0); - return isa(Token) || isa(Token); + return isa(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(V) || isa(V); + return isa(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(V) || isa(V); - } + static bool classof(const Value *V) { return isa(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 { template <> struct isa_impl { static inline bool doit(const Value &Val) { - return isa(Val) || isa(Val); + return isa(Val); } }; template <> struct isa_impl { static inline bool doit(const Value &Val) { - return isa(Val) || isa(Val) || - isa(Val); + return isa(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(V) || isa(V)) + if (isa(V)) orderValue(V, OM); }; @@ -1625,7 +1625,7 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV, return; } - if (isa(CV) || isa(CV)) { + if (isa(CV)) { Out << "zeroinitializer"; return; } @@ -1741,7 +1741,7 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV, return; } - if (isa(CV) || isa(CV)) { + if (isa(CV)) { auto *CVVTy = cast(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(SplatVal) || isa(SplatVal)) { + if (isa(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(SplatVal) || isa(SplatVal)) { + if (isa(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(I) || isa(I) || isa(I) || - isa(I) || isa(I) || - isa(I)) { + if (isa(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(this)) ShouldInitializeAllMetadata = isReferencingMDNode(*I); - else if (isa(this) || isa(this)) + else if (isa(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(this) || isa(this)) { + } else if (isa(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(I) || isa(I) || isa(I)) + if (isa(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(I) || isa(I)) + if (isa(I)) continue; if (SkipPseudoOp && isa(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(I) || isa(I)) + if (isa(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(*InsertPt) || isa(*InsertPt) || - isa(*InsertPt))) { + isa(*InsertPt)) { if (const AllocaInst *AI = dyn_cast(&*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(C)) return false; - if (isa(C) || isa(C) || isa(C) || - isa(C) || isa(C)) + if (isa(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(this) || isa(this) || - isa(this) || isa(this); + return isa(this); } bool Constant::isAllOnesValue() const { @@ -358,7 +358,7 @@ bool Constant::containsUndefElement() const { } bool Constant::containsConstantExpression() const { - if (isa(this) || isa(this)) + if (isa(this)) return false; if (auto *VTy = dyn_cast(getType())) { @@ -845,7 +845,7 @@ bool Constant::isManifestConstant() const { return false; if (isa(this)) return true; - if (isa(this) || isa(this)) { + if (isa(this)) { for (const Value *Op : operand_values()) if (!cast(Op)->isManifestConstant()) return false; @@ -1142,13 +1142,13 @@ Constant *ConstantAggregateZero::getStructElement(unsigned Elt) const { } Constant *ConstantAggregateZero::getElementValue(Constant *C) const { - if (isa(getType()) || isa(getType())) + if (isa(getType())) return getSequentialElement(); return getStructElement(cast(C)->getZExtValue()); } Constant *ConstantAggregateZero::getElementValue(unsigned Idx) const { - if (isa(getType()) || isa(getType())) + if (isa(getType())) return getSequentialElement(); return getStructElement(Idx); } @@ -1177,13 +1177,13 @@ UndefValue *UndefValue::getStructElement(unsigned Elt) const { } UndefValue *UndefValue::getElementValue(Constant *C) const { - if (isa(getType()) || isa(getType())) + if (isa(getType())) return getSequentialElement(); return getStructElement(cast(C)->getZExtValue()); } UndefValue *UndefValue::getElementValue(unsigned Idx) const { - if (isa(getType()) || isa(getType())) + if (isa(getType())) return getSequentialElement(); return getStructElement(Idx); } @@ -1212,13 +1212,13 @@ PoisonValue *PoisonValue::getStructElement(unsigned Elt) const { } PoisonValue *PoisonValue::getElementValue(Constant *C) const { - if (isa(getType()) || isa(getType())) + if (isa(getType())) return getSequentialElement(); return getStructElement(cast(C)->getZExtValue()); } PoisonValue *PoisonValue::getElementValue(unsigned Idx) const { - if (isa(getType()) || isa(getType())) + if (isa(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(V) || isa(V)) && + if ((isa(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(MD) || isa(MD)) && - "Expected a metadata node or a canonicalized constant"); + assert((isa(MD)) && + "Expected a metadata node or a canonicalized constant"); if (MDNode *N = dyn_cast(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(this)) return M->getScope(); - assert((isa(this) || isa(this)) && - "Unhandled type of scope."); + assert((isa(this)) && "Unhandled type of scope."); return nullptr; } @@ -492,8 +491,7 @@ StringRef DIScope::getName() const { return CB->getName(); if (auto *M = dyn_cast(this)) return M->getName(); - assert((isa(this) || isa(this) || - isa(this)) && + assert((isa(this)) && "Unhandled type of scope."); return ""; } @@ -599,8 +597,7 @@ DISubrange::BoundType DISubrange::getCount() const { if (!CB) return BoundType(); - assert((isa(CB) || isa(CB) || - isa(CB)) && + assert((isa(CB)) && "Count must be signed constant or DIVariable or DIExpression"); if (auto *MD = dyn_cast(CB)) @@ -620,8 +617,7 @@ DISubrange::BoundType DISubrange::getLowerBound() const { if (!LB) return BoundType(); - assert((isa(LB) || isa(LB) || - isa(LB)) && + assert((isa(LB)) && "LowerBound must be signed constant or DIVariable or DIExpression"); if (auto *MD = dyn_cast(LB)) @@ -641,8 +637,7 @@ DISubrange::BoundType DISubrange::getUpperBound() const { if (!UB) return BoundType(); - assert((isa(UB) || isa(UB) || - isa(UB)) && + assert((isa(UB)) && "UpperBound must be signed constant or DIVariable or DIExpression"); if (auto *MD = dyn_cast(UB)) @@ -662,8 +657,7 @@ DISubrange::BoundType DISubrange::getStride() const { if (!ST) return BoundType(); - assert((isa(ST) || isa(ST) || - isa(ST)) && + assert((isa(ST)) && "Stride must be signed constant or DIVariable or DIExpression"); if (auto *MD = dyn_cast(ST)) @@ -697,7 +691,7 @@ DIGenericSubrange::BoundType DIGenericSubrange::getCount() const { if (!CB) return BoundType(); - assert((isa(CB) || isa(CB)) && + assert((isa(CB)) && "Count must be signed constant or DIVariable or DIExpression"); if (auto *MD = dyn_cast(CB)) @@ -714,7 +708,7 @@ DIGenericSubrange::BoundType DIGenericSubrange::getLowerBound() const { if (!LB) return BoundType(); - assert((isa(LB) || isa(LB)) && + assert((isa(LB)) && "LowerBound must be signed constant or DIVariable or DIExpression"); if (auto *MD = dyn_cast(LB)) @@ -731,7 +725,7 @@ DIGenericSubrange::BoundType DIGenericSubrange::getUpperBound() const { if (!UB) return BoundType(); - assert((isa(UB) || isa(UB)) && + assert((isa(UB)) && "UpperBound must be signed constant or DIVariable or DIExpression"); if (auto *MD = dyn_cast(UB)) @@ -748,7 +742,7 @@ DIGenericSubrange::BoundType DIGenericSubrange::getStride() const { if (!ST) return BoundType(); - assert((isa(ST) || isa(ST)) && + assert((isa(ST)) && "Stride must be signed constant or DIVariable or DIExpression"); if (auto *MD = dyn_cast(ST)) @@ -787,8 +781,7 @@ DISubrangeType::convertRawToBound(Metadata *IN) const { if (!IN) return BoundType(); - assert(isa(IN) || isa(IN) || - isa(IN)); + assert((isa(IN))); if (auto *MD = dyn_cast(IN)) return BoundType(cast(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(V) || isa(V)) + if (isa(V)) Val = std::string(GlobalValue::dropLLVMManglingEscape(V->getName())); else if (isa(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(DefV); if (!Def) { - assert((isa(DefV) || isa(DefV)) && + assert((isa(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(Def) || isa(Def) || isa(User)) + if (isa(Def) || isa(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(DefV); if (!Def) { - assert((isa(DefV) || isa(DefV)) && + assert((isa(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(this) || isa(this)); + assert((isa(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(this) || isa(this); + return isa(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(V) || isa(V)) + if (isa(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(Mask) || isa(Mask)) + if (isa(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(Mask) || isa(Mask)) && + assert((isa(Mask)) && "Scalable vector shuffle mask must be undef or zeroinitializer"); int MaskVal = isa(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(I) || isa(I) || isa(I) || - isa(I) || isa(I) || isReadWriteMemCall(I); + return isa( + 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(&MD)) return !N->isResolved() || N->isAlwaysReplaceable(); - return isa(&MD) || isa(&MD); + return isa(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(V) || isa(V) || isa(V)) && + assert((isa(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(this) || isa(this)); + assert((isa(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(this) || isa(this)); - if (!HasMetadata) - HasMetadata = true; + assert((isa(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(U) || isa(U); + return isa(U); } static SmallVector expandUser(BasicBlock::iterator InsertPt, @@ -29,7 +29,7 @@ static SmallVector expandUser(BasicBlock::iterator InsertPt, Instruction *ConstInst = CE->getAsInstruction(); ConstInst->insertBefore(*InsertPt->getParent(), InsertPt); NewInsts.push_back(ConstInst); - } else if (isa(C) || isa(C)) { + } else if (isa(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(I) || isa(I)) && + } else if (isa(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(V)) { diff --git a/llvm/lib/IR/User.cpp b/llvm/lib/IR/User.cpp index ab44cb4b8a3f7..23efa9ea6d4a6 100644 --- a/llvm/lib/IR/User.cpp +++ b/llvm/lib/IR/User.cpp @@ -22,6 +22,7 @@ bool User::replaceUsesOfWith(Value *From, Value *To) { bool Changed = false; if (From == To) return Changed; // Duh what? + // Allow GlobalValue explicitly, since its a subclass of Constant. assert((!isa(this) || isa(this)) && "Cannot call User::replaceUsesOfWith on a constant!");