diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -764,8 +764,7 @@ Init); for (Value *Op : InitArray->operands()) { Value *V = Op->stripPointerCasts(); - Check(isa(V) || isa(V) || - isa(V), + Check((isa(V)), Twine("invalid ") + GV.getName() + " member", V); Check(V->hasName(), Twine("members of ") + GV.getName() + " must be named", V); @@ -853,7 +852,7 @@ Check(GA.getType() == Aliasee->getType(), "Alias and aliasee types should match!", &GA); - Check(isa(Aliasee) || isa(Aliasee), + Check((isa(Aliasee)), "Aliasee should be either GlobalValue or ConstantExpr", &GA); visitAliaseeSubExpr(GA, *Aliasee); @@ -1015,27 +1014,25 @@ CheckDI(!N.getRawCountNode() || !N.getRawUpperBound(), "Subrange can have any one of count or upperBound", &N); auto *CBound = N.getRawCountNode(); - CheckDI(!CBound || isa(CBound) || - isa(CBound) || isa(CBound), - "Count must be signed constant or DIVariable or DIExpression", &N); + CheckDI( + (!CBound || isa(CBound)), + "Count must be signed constant or DIVariable or DIExpression", &N); auto Count = N.getCount(); CheckDI(!Count || !Count.is() || Count.get()->getSExtValue() >= -1, "invalid subrange count", &N); auto *LBound = N.getRawLowerBound(); - CheckDI(!LBound || isa(LBound) || - isa(LBound) || isa(LBound), - "LowerBound must be signed constant or DIVariable or DIExpression", - &N); + CheckDI( + (!LBound || isa(LBound)), + "LowerBound must be signed constant or DIVariable or DIExpression", &N); auto *UBound = N.getRawUpperBound(); - CheckDI(!UBound || isa(UBound) || - isa(UBound) || isa(UBound), - "UpperBound must be signed constant or DIVariable or DIExpression", - &N); + CheckDI( + (!UBound || isa(UBound)), + "UpperBound must be signed constant or DIVariable or DIExpression", &N); auto *Stride = N.getRawStride(); - CheckDI(!Stride || isa(Stride) || - isa(Stride) || isa(Stride), - "Stride must be signed constant or DIVariable or DIExpression", &N); + CheckDI( + (!Stride || isa(Stride)), + "Stride must be signed constant or DIVariable or DIExpression", &N); } void Verifier::visitDIGenericSubrange(const DIGenericSubrange &N) { @@ -1045,21 +1042,19 @@ CheckDI(!N.getRawCountNode() || !N.getRawUpperBound(), "GenericSubrange can have any one of count or upperBound", &N); auto *CBound = N.getRawCountNode(); - CheckDI(!CBound || isa(CBound) || isa(CBound), - "Count must be signed constant or DIVariable or DIExpression", &N); + CheckDI((!CBound || isa(CBound)), + "Count must be DIVariable or DIExpression", &N); auto *LBound = N.getRawLowerBound(); CheckDI(LBound, "GenericSubrange must contain lowerBound", &N); - CheckDI(isa(LBound) || isa(LBound), - "LowerBound must be signed constant or DIVariable or DIExpression", - &N); + CheckDI((isa(LBound)), + "LowerBound must be DIVariable or DIExpression", &N); auto *UBound = N.getRawUpperBound(); - CheckDI(!UBound || isa(UBound) || isa(UBound), - "UpperBound must be signed constant or DIVariable or DIExpression", - &N); + CheckDI((!UBound || isa(UBound)), + "UpperBound must be DIVariable or DIExpression", &N); auto *Stride = N.getRawStride(); CheckDI(Stride, "GenericSubrange must contain stride", &N); - CheckDI(isa(Stride) || isa(Stride), - "Stride must be signed constant or DIVariable or DIExpression", &N); + CheckDI((isa(Stride)), + "Stride must be DIVariable or DIExpression", &N); } void Verifier::visitDIEnumerator(const DIEnumerator &N) { @@ -1325,7 +1320,7 @@ auto *Node = dyn_cast(RawNode); CheckDI(Node, "invalid retained nodes list", &N, RawNode); for (Metadata *Op : Node->operands()) { - CheckDI(Op && (isa(Op) || isa(Op)), + CheckDI(Op && (isa(Op)), "invalid retained nodes, expected DILocalVariable or DILabel", &N, Node, Op); } @@ -2380,23 +2375,18 @@ // Check that the only uses of this gc.statepoint are gc.result or // gc.relocate calls which are tied to this statepoint and thus part - // of the same statepoint sequence + // of the same statepoint sequence. for (const User *U : Call.users()) { const CallInst *UserCall = dyn_cast(U); Check(UserCall, "illegal use of statepoint token", Call, U); - if (!UserCall) - continue; - Check(isa(UserCall) || isa(UserCall), - "gc.result or gc.relocate are the only value uses " + Check((isa(UserCall)), + "gc.result or gc.relocate are the only valid uses " "of a gc.statepoint", Call, U); - if (isa(UserCall)) { - Check(UserCall->getArgOperand(0) == &Call, - "gc.result connected to wrong gc.statepoint", Call, UserCall); - } else if (isa(Call)) { - Check(UserCall->getArgOperand(0) == &Call, - "gc.relocate connected to wrong gc.statepoint", Call, UserCall); - } + Check(UserCall->getArgOperand(0) == &Call, + Twine(isa(UserCall) ? "gc.relocate" : "gc.result", + StringRef(" result connected to wrong gc.statepoint")), + Call, UserCall); } // Note: It is legal for a single derived pointer to be listed multiple @@ -3303,7 +3293,7 @@ if (Call.paramHasAttr(i, Attribute::ImmArg)) { Value *ArgVal = Call.getArgOperand(i); - Check(isa(ArgVal) || isa(ArgVal), + Check((isa(ArgVal)), "immarg operand has non-immediate parameter", ArgVal, Call); } @@ -3949,8 +3939,7 @@ // Check that swifterror value is only used by loads, stores, or as // a swifterror argument. for (const User *U : SwiftErrorVal->users()) { - Check(isa(U) || isa(U) || isa(U) || - isa(U), + Check((isa(U)), "swifterror value can only be loaded and stored from, or " "as a swifterror argument!", SwiftErrorVal, U); @@ -4131,7 +4120,7 @@ // This will be diagnosed on the corresponding instruction already. We // need the extra check here to make sure getParentPad() works. - Check(isa(FromPad) || isa(FromPad), + Check((isa(FromPad)), "Parent pad must be catchpad/cleanuppad/catchswitch", TI); } } @@ -4169,7 +4158,7 @@ "Catch operand does not have pointer type!", &LPI); } else { Check(LPI.isFilter(i), "Clause is neither catch nor filter!", &LPI); - Check(isa(Clause) || isa(Clause), + Check((isa(Clause)), "Filter operand is not an array of constants!", &LPI); } } @@ -4233,7 +4222,7 @@ "CleanupPadInst not the first non-PHI instruction in the block.", &CPI); auto *ParentPad = CPI.getParentPad(); - Check(isa(ParentPad) || isa(ParentPad), + Check((isa(ParentPad)), "CleanupPadInst has an invalid parent.", &CPI); visitEHPadPredecessors(CPI); @@ -4415,7 +4404,7 @@ &CatchSwitch); auto *ParentPad = CatchSwitch.getParentPad(); - Check(isa(ParentPad) || isa(ParentPad), + Check((isa(ParentPad)), "CatchSwitchInst has an invalid parent.", ParentPad); if (BasicBlock *UnwindDest = CatchSwitch.getUnwindDest()) { @@ -4487,7 +4476,7 @@ "dereferenceable, dereferenceable_or_null " "apply only to pointer types", &I); - Check((isa(I) || isa(I)), + Check((isa(I)), "dereferenceable, dereferenceable_or_null apply only to load" " and inttoptr instructions, use attributes for calls or invokes", &I); @@ -4679,7 +4668,7 @@ // Check that the instruction doesn't produce metadata. Calls are already // checked against the callee type. - Check(!I.getType()->isMetadataTy() || isa(I) || isa(I), + Check((!I.getType()->isMetadataTy() || isa(I)), "Invalid use of metadata!", &I); // Check that all uses of the instruction, if they are instructions @@ -4786,13 +4775,13 @@ } if (MDNode *Range = I.getMetadata(LLVMContext::MD_range)) { - Check(isa(I) || isa(I) || isa(I), + Check((isa(I)), "Ranges are only for loads, calls and invokes!", &I); visitRangeMetadata(I, Range, I.getType()); } if (I.hasMetadata(LLVMContext::MD_invariant_group)) { - Check(isa(I) || isa(I), + Check((isa(I)), "invariant.group metadata is only for loads and stores", &I); } @@ -4980,7 +4969,7 @@ "info argument of llvm.coro.id must refer to an initialized " "constant"); Constant *Init = GV->getInitializer(); - Check(isa(Init) || isa(Init), + Check((isa(Init)), "info argument of llvm.coro.id must refer to either a struct or " "an array"); break; @@ -5278,7 +5267,7 @@ // This covers relocates on a normal return path of invoke statepoint and // relocates of a call statepoint. auto *Token = Call.getArgOperand(0); - Check(isa(Token) || isa(Token), + Check((isa(Token)), "gc relocate is incorrectly tied to the statepoint", Call, Token); } @@ -5973,7 +5962,7 @@ void Verifier::visitDbgIntrinsic(StringRef Kind, DbgVariableIntrinsic &DII) { auto *MD = DII.getRawLocation(); - CheckDI(isa(MD) || isa(MD) || + CheckDI((isa(MD)) || (isa(MD) && !cast(MD)->getNumOperands()), "invalid llvm.dbg." + Kind + " intrinsic address/value", &DII, MD); CheckDI(isa(DII.getRawVariable()), @@ -6582,9 +6571,8 @@ } bool TBAAVerifier::visitTBAAMetadata(Instruction &I, const MDNode *MD) { - CheckTBAA(isa(I) || isa(I) || isa(I) || - isa(I) || isa(I) || - isa(I), + CheckTBAA((isa(I)), "This instruction shall not have a TBAA access tag!", &I); bool IsStructPathTBAA =