Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions llvm/include/llvm/IR/DebugProgramInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/IR/InstVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 4 additions & 8 deletions llvm/include/llvm/IR/Instructions.h
Original file line number Diff line number Diff line change
Expand Up @@ -5023,17 +5023,15 @@ 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();
}

/// 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
Expand All @@ -5043,17 +5041,15 @@ 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();
}

/// 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();
Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/IR/IntrinsicInst.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/IR/Operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions llvm/include/llvm/IR/User.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions llvm/include/llvm/IR/Value.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

Expand Down
19 changes: 9 additions & 10 deletions llvm/lib/IR/AsmWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();

Expand All @@ -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 << ' ';
Expand Down Expand Up @@ -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 << ' ';
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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!");
Expand Down
9 changes: 4 additions & 5 deletions llvm/lib/IR/BasicBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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))
Expand All @@ -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())
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/IR/ConstantFold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
22 changes: 11 additions & 11 deletions llvm/lib/IR/Constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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())) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/IR/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading
Loading