[llvm] [llvm] Use dyn_cast_if_present instead of dyn_cast_and_nonnull (NFC) (PR #75733)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 16 23:39:24 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-amdgpu
@llvm/pr-subscribers-backend-aarch64
@llvm/pr-subscribers-backend-arm
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
Note that dyn_cast_and_nonnull has been soft-deprecated since:
commit f156b51aecc676a9051136f6f5cb74e37dd574d1
Author: bzcheeseman <12992886+bzcheeseman@<!-- -->users.noreply.github.com>
Date: Sat Apr 16 11:34:08 2022 -0700
---
Patch is 300.00 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/75733.diff
212 Files Affected:
- (modified) llvm/include/llvm/Analysis/SparsePropagation.h (+4-3)
- (modified) llvm/include/llvm/CodeGen/BasicTTIImpl.h (+2-2)
- (modified) llvm/include/llvm/CodeGen/GlobalISel/Utils.h (+1-1)
- (modified) llvm/include/llvm/IR/DebugInfoMetadata.h (+10-10)
- (modified) llvm/include/llvm/IR/InstrTypes.h (+1-1)
- (modified) llvm/include/llvm/IR/Metadata.h (+3-3)
- (modified) llvm/include/llvm/IR/PatternMatch.h (+9-8)
- (modified) llvm/include/llvm/IR/Statepoint.h (+1-1)
- (modified) llvm/include/llvm/ProfileData/InstrProfReader.h (+1-1)
- (modified) llvm/lib/Analysis/CallGraphSCCPass.cpp (+1-1)
- (modified) llvm/lib/Analysis/ConstantFolding.cpp (+8-8)
- (modified) llvm/lib/Analysis/IVDescriptors.cpp (+1-1)
- (modified) llvm/lib/Analysis/InlineCost.cpp (+11-11)
- (modified) llvm/lib/Analysis/InstructionSimplify.cpp (+1-1)
- (modified) llvm/lib/Analysis/LazyValueInfo.cpp (+4-5)
- (modified) llvm/lib/Analysis/LoopAccessAnalysis.cpp (+3-3)
- (modified) llvm/lib/Analysis/LoopCacheAnalysis.cpp (+1-1)
- (modified) llvm/lib/Analysis/LoopInfo.cpp (+4-3)
- (modified) llvm/lib/Analysis/MemoryDependenceAnalysis.cpp (+2-2)
- (modified) llvm/lib/Analysis/MemorySSA.cpp (+2-2)
- (modified) llvm/lib/Analysis/MemorySSAUpdater.cpp (+5-5)
- (modified) llvm/lib/Analysis/MustExecute.cpp (+1-1)
- (modified) llvm/lib/Analysis/PHITransAddr.cpp (+1-1)
- (modified) llvm/lib/Analysis/ScalarEvolution.cpp (+1-1)
- (modified) llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp (+5-5)
- (modified) llvm/lib/Analysis/ValueTracking.cpp (+8-8)
- (modified) llvm/lib/AsmParser/LLParser.cpp (+3-3)
- (modified) llvm/lib/Bitcode/Reader/BitcodeReader.cpp (+16-15)
- (modified) llvm/lib/Bitcode/Reader/MetadataLoader.cpp (+19-18)
- (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (+2-2)
- (modified) llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (+9-9)
- (modified) llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (+8-6)
- (modified) llvm/lib/CodeGen/CodeGenPrepare.cpp (+5-5)
- (modified) llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp (+1-1)
- (modified) llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp (+1-1)
- (modified) llvm/lib/CodeGen/GlobalISel/Utils.cpp (+1-1)
- (modified) llvm/lib/CodeGen/LowerEmuTLS.cpp (+1-1)
- (modified) llvm/lib/CodeGen/MIRParser/MIParser.cpp (+2-2)
- (modified) llvm/lib/CodeGen/MIRParser/MIRParser.cpp (+3-3)
- (modified) llvm/lib/CodeGen/MachineFunction.cpp (+1-1)
- (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (+5-5)
- (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (+8-7)
- (modified) llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp (+1-1)
- (modified) llvm/lib/CodeGen/StackColoring.cpp (+3-3)
- (modified) llvm/lib/CodeGen/StackFrameLayoutAnalysisPass.cpp (+1-1)
- (modified) llvm/lib/CodeGen/StackSlotColoring.cpp (+2-2)
- (modified) llvm/lib/CodeGen/TargetLoweringBase.cpp (+2-2)
- (modified) llvm/lib/CodeGen/WinEHPrepare.cpp (+2-2)
- (modified) llvm/lib/DebugInfo/DWARF/DWARFContext.cpp (+3-3)
- (modified) llvm/lib/DebugInfo/PDB/PDBContext.cpp (+5-4)
- (modified) llvm/lib/DebugInfo/PDB/PDBSymbolTypeFunctionSig.cpp (+2-1)
- (modified) llvm/lib/DebugInfo/Symbolize/Symbolize.cpp (+2-1)
- (modified) llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp (+5-6)
- (modified) llvm/lib/IR/AsmWriter.cpp (+9-9)
- (modified) llvm/lib/IR/AutoUpgrade.cpp (+8-8)
- (modified) llvm/lib/IR/BasicBlock.cpp (+1-1)
- (modified) llvm/lib/IR/ConstantFold.cpp (+1-1)
- (modified) llvm/lib/IR/Constants.cpp (+10-10)
- (modified) llvm/lib/IR/Core.cpp (+6-6)
- (modified) llvm/lib/IR/DIBuilder.cpp (+2-2)
- (modified) llvm/lib/IR/DebugInfo.cpp (+7-7)
- (modified) llvm/lib/IR/DebugInfoMetadata.cpp (+1-1)
- (modified) llvm/lib/IR/LLVMContextImpl.h (+7-7)
- (modified) llvm/lib/IR/Mangler.cpp (+2-1)
- (modified) llvm/lib/IR/Metadata.cpp (+3-3)
- (modified) llvm/lib/IR/Module.cpp (+11-11)
- (modified) llvm/lib/IR/ModuleSummaryIndex.cpp (+4-4)
- (modified) llvm/lib/IR/ProfileSummary.cpp (+6-6)
- (modified) llvm/lib/IR/Type.cpp (+1-1)
- (modified) llvm/lib/IR/User.cpp (+1-1)
- (modified) llvm/lib/IR/Value.cpp (+4-3)
- (modified) llvm/lib/IR/Verifier.cpp (+22-22)
- (modified) llvm/lib/LTO/LTO.cpp (+1-1)
- (modified) llvm/lib/Linker/LinkModules.cpp (+2-2)
- (modified) llvm/lib/MC/MCObjectStreamer.cpp (+3-3)
- (modified) llvm/lib/MC/MCParser/ELFAsmParser.cpp (+2-1)
- (modified) llvm/lib/MC/MCParser/MasmParser.cpp (+1-1)
- (modified) llvm/lib/MC/MachObjectWriter.cpp (+1-1)
- (modified) llvm/lib/Object/ArchiveWriter.cpp (+1-1)
- (modified) llvm/lib/ObjectYAML/ELFEmitter.cpp (+3-3)
- (modified) llvm/lib/ProfileData/InstrProf.cpp (+2-1)
- (modified) llvm/lib/Support/YAMLTraits.cpp (+3-3)
- (modified) llvm/lib/TableGen/Error.cpp (+3-2)
- (modified) llvm/lib/TableGen/Record.cpp (+13-13)
- (modified) llvm/lib/TableGen/TGParser.cpp (+2-2)
- (modified) llvm/lib/Target/AArch64/AArch64ISelLowering.cpp (+6-6)
- (modified) llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp (+1-1)
- (modified) llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp (+7-6)
- (modified) llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (+2-2)
- (modified) llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp (+1-1)
- (modified) llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp (+6-6)
- (modified) llvm/lib/Target/AMDGPU/AMDGPULibFunc.cpp (+4-4)
- (modified) llvm/lib/Target/AMDGPU/AMDGPUPerfHintAnalysis.cpp (+1-1)
- (modified) llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp (+2-2)
- (modified) llvm/lib/Target/AMDGPU/R600OpenCLImageTypeLoweringPass.cpp (+1-1)
- (modified) llvm/lib/Target/ARM/ARMConstantPoolValue.cpp (+2-2)
- (modified) llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp (+1-1)
- (modified) llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (+2-2)
- (modified) llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp (+3-2)
- (modified) llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp (+1-1)
- (modified) llvm/lib/Target/BPF/BTFDebug.cpp (+1-1)
- (modified) llvm/lib/Target/DirectX/DirectXIRPasses/PointerTypeAnalysis.cpp (+1-1)
- (modified) llvm/lib/Target/Hexagon/HexagonISelLowering.cpp (+1-1)
- (modified) llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp (+1-1)
- (modified) llvm/lib/Target/LoongArch/LoongArchTargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/Mips/MipsISelLowering.cpp (+6-6)
- (modified) llvm/lib/Target/NVPTX/NVPTXLowerUnreachable.cpp (+1-1)
- (modified) llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp (+1-1)
- (modified) llvm/lib/Target/PowerPC/PPCFastISel.cpp (+1-1)
- (modified) llvm/lib/Target/PowerPC/PPCGenScalarMASSEntries.cpp (+1-1)
- (modified) llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp (+3-2)
- (modified) llvm/lib/Target/PowerPC/PPCISelLowering.cpp (+1-1)
- (modified) llvm/lib/Target/PowerPC/PPCLowerMASSVEntries.cpp (+2-1)
- (modified) llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp (+3-2)
- (modified) llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp (+1-1)
- (modified) llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp (+4-4)
- (modified) llvm/lib/Target/RISCV/RISCVTargetMachine.cpp (+1-1)
- (modified) llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp (+1-1)
- (modified) llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp (+1-1)
- (modified) llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp (+2-2)
- (modified) llvm/lib/Target/X86/X86FrameLowering.cpp (+2-1)
- (modified) llvm/lib/Target/X86/X86ISelDAGToDAG.cpp (+3-3)
- (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+1-1)
- (modified) llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp (+19-19)
- (modified) llvm/lib/Target/X86/X86Subtarget.cpp (+1-1)
- (modified) llvm/lib/Target/X86/X86TargetTransformInfo.cpp (+1-1)
- (modified) llvm/lib/Transforms/Coroutines/CoroFrame.cpp (+3-3)
- (modified) llvm/lib/Transforms/Coroutines/CoroSplit.cpp (+1-1)
- (modified) llvm/lib/Transforms/IPO/Annotation2Metadata.cpp (+1-1)
- (modified) llvm/lib/Transforms/IPO/Attributor.cpp (+5-5)
- (modified) llvm/lib/Transforms/IPO/AttributorAttributes.cpp (+7-7)
- (modified) llvm/lib/Transforms/IPO/CrossDSOCFI.cpp (+1-1)
- (modified) llvm/lib/Transforms/IPO/FunctionImport.cpp (+2-2)
- (modified) llvm/lib/Transforms/IPO/FunctionSpecialization.cpp (+3-3)
- (modified) llvm/lib/Transforms/IPO/GlobalSplit.cpp (+1-1)
- (modified) llvm/lib/Transforms/IPO/HotColdSplitting.cpp (+1-1)
- (modified) llvm/lib/Transforms/IPO/IROutliner.cpp (+1-1)
- (modified) llvm/lib/Transforms/IPO/MergeFunctions.cpp (+1-1)
- (modified) llvm/lib/Transforms/IPO/OpenMPOpt.cpp (+1-1)
- (modified) llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp (+5-3)
- (modified) llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp (+3-2)
- (modified) llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp (+1-1)
- (modified) llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp (+2-2)
- (modified) llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp (+3-3)
- (modified) llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp (+1-1)
- (modified) llvm/lib/Transforms/InstCombine/InstructionCombining.cpp (+1-1)
- (modified) llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp (+1-1)
- (modified) llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp (+1-1)
- (modified) llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp (+2-2)
- (modified) llvm/lib/Transforms/Instrumentation/MemProfiler.cpp (+1-1)
- (modified) llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp (+3-3)
- (modified) llvm/lib/Transforms/ObjCARC/ObjCARC.h (+1-1)
- (modified) llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp (+1-1)
- (modified) llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp (+3-3)
- (modified) llvm/lib/Transforms/Scalar/ConstraintElimination.cpp (+1-1)
- (modified) llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp (+1-1)
- (modified) llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp (+3-2)
- (modified) llvm/lib/Transforms/Scalar/IndVarSimplify.cpp (+3-3)
- (modified) llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp (+1-1)
- (modified) llvm/lib/Transforms/Scalar/JumpThreading.cpp (+1-1)
- (modified) llvm/lib/Transforms/Scalar/LoopInstSimplify.cpp (+1-1)
- (modified) llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp (+5-8)
- (modified) llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp (+1-1)
- (modified) llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp (+5-5)
- (modified) llvm/lib/Transforms/Scalar/NaryReassociate.cpp (+2-2)
- (modified) llvm/lib/Transforms/Scalar/NewGVN.cpp (+8-7)
- (modified) llvm/lib/Transforms/Scalar/SROA.cpp (+2-2)
- (modified) llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp (+1-1)
- (modified) llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp (+1-1)
- (modified) llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp (+1-1)
- (modified) llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp (+1-1)
- (modified) llvm/lib/Transforms/Scalar/StructurizeCFG.cpp (+1-1)
- (modified) llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp (+2-2)
- (modified) llvm/lib/Transforms/Utils/BasicBlockUtils.cpp (+2-2)
- (modified) llvm/lib/Transforms/Utils/CallPromotionUtils.cpp (+2-2)
- (modified) llvm/lib/Transforms/Utils/CloneFunction.cpp (+3-3)
- (modified) llvm/lib/Transforms/Utils/CodeExtractor.cpp (+3-3)
- (modified) llvm/lib/Transforms/Utils/FunctionImportUtils.cpp (+1-1)
- (modified) llvm/lib/Transforms/Utils/InlineFunction.cpp (+7-7)
- (modified) llvm/lib/Transforms/Utils/Local.cpp (+7-7)
- (modified) llvm/lib/Transforms/Utils/LoopUnroll.cpp (+1-1)
- (modified) llvm/lib/Transforms/Utils/LoopUtils.cpp (+1-1)
- (modified) llvm/lib/Transforms/Utils/MemoryTaggingSupport.cpp (+1-1)
- (modified) llvm/lib/Transforms/Utils/PredicateInfo.cpp (+5-5)
- (modified) llvm/lib/Transforms/Utils/SCCPSolver.cpp (+3-3)
- (modified) llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp (+1-1)
- (modified) llvm/lib/Transforms/Utils/SplitModule.cpp (+1-1)
- (modified) llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp (+1-1)
- (modified) llvm/lib/Transforms/Vectorize/LoopVectorize.cpp (+4-4)
- (modified) llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp (+4-4)
- (modified) llvm/lib/Transforms/Vectorize/VPlan.cpp (+5-4)
- (modified) llvm/lib/Transforms/Vectorize/VPlan.h (+3-3)
- (modified) llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp (+13-10)
- (modified) llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp (+8-7)
- (modified) llvm/lib/Transforms/Vectorize/VectorCombine.cpp (+2-2)
- (modified) llvm/tools/llvm-reduce/deltas/ReduceDIMetadata.cpp (+3-3)
- (modified) llvm/tools/llvm-reduce/deltas/ReduceOpcodes.cpp (+1-1)
- (modified) llvm/unittests/Analysis/LoopInfoTest.cpp (+17-16)
- (modified) llvm/unittests/Analysis/MemorySSATest.cpp (+3-3)
- (modified) llvm/unittests/Analysis/VectorFunctionABITest.cpp (+1-1)
- (modified) llvm/unittests/CodeGen/AsmPrinterDwarfTest.cpp (+14-10)
- (modified) llvm/unittests/CodeGen/DIETest.cpp (+2-1)
- (modified) llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp (+8-7)
- (modified) llvm/unittests/IR/IRBuilderTest.cpp (+1-1)
- (modified) llvm/unittests/IR/MetadataTest.cpp (+4-3)
- (modified) llvm/unittests/Support/Casting.cpp (+11-11)
- (modified) llvm/unittests/Transforms/Utils/SSAUpdaterBulkTest.cpp (+5-5)
- (modified) llvm/utils/TableGen/CodeEmitterGen.cpp (+3-3)
- (modified) llvm/utils/TableGen/CodeGenInstAlias.cpp (+1-1)
- (modified) llvm/utils/TableGen/CodeGenRegisters.cpp (+1-1)
- (modified) llvm/utils/TableGen/DecoderEmitter.cpp (+2-2)
- (modified) llvm/utils/TableGen/VarLenCodeEmitterGen.cpp (+1-1)
``````````diff
diff --git a/llvm/include/llvm/Analysis/SparsePropagation.h b/llvm/include/llvm/Analysis/SparsePropagation.h
index d5805a7314757f..1d58b82d57ff08 100644
--- a/llvm/include/llvm/Analysis/SparsePropagation.h
+++ b/llvm/include/llvm/Analysis/SparsePropagation.h
@@ -318,7 +318,7 @@ void SparseSolver<LatticeKey, LatticeVal, KeyInfo>::getFeasibleSuccessors(
return;
Constant *C =
- dyn_cast_or_null<Constant>(LatticeFunc->GetValueFromLatticeVal(
+ dyn_cast_if_present<Constant>(LatticeFunc->GetValueFromLatticeVal(
std::move(BCValue), BI->getCondition()->getType()));
if (!C || !isa<ConstantInt>(C)) {
// Non-constant values can go either way.
@@ -356,8 +356,9 @@ void SparseSolver<LatticeKey, LatticeVal, KeyInfo>::getFeasibleSuccessors(
if (SCValue == LatticeFunc->getUndefVal())
return;
- Constant *C = dyn_cast_or_null<Constant>(LatticeFunc->GetValueFromLatticeVal(
- std::move(SCValue), SI.getCondition()->getType()));
+ Constant *C =
+ dyn_cast_if_present<Constant>(LatticeFunc->GetValueFromLatticeVal(
+ std::move(SCValue), SI.getCondition()->getType()));
if (!C || !isa<ConstantInt>(C)) {
// All destinations are executable!
Succs.assign(TI.getNumSuccessors(), true);
diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
index 5e7bdcdf72a49f..6528281be426e6 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -1730,7 +1730,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
if (FOp) {
if (ICA.getID() == Intrinsic::vp_load) {
Align Alignment;
- if (auto *VPI = dyn_cast_or_null<VPIntrinsic>(ICA.getInst()))
+ if (auto *VPI = dyn_cast_if_present<VPIntrinsic>(ICA.getInst()))
Alignment = VPI->getPointerAlignment().valueOrOne();
unsigned AS = 0;
if (ICA.getArgs().size() > 1)
@@ -1742,7 +1742,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
}
if (ICA.getID() == Intrinsic::vp_store) {
Align Alignment;
- if (auto *VPI = dyn_cast_or_null<VPIntrinsic>(ICA.getInst()))
+ if (auto *VPI = dyn_cast_if_present<VPIntrinsic>(ICA.getInst()))
Alignment = VPI->getPointerAlignment().valueOrOne();
unsigned AS = 0;
if (ICA.getArgs().size() >= 2)
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/Utils.h b/llvm/include/llvm/CodeGen/GlobalISel/Utils.h
index ffb6e53a0363f9..ef81a1a3ea0221 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/Utils.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/Utils.h
@@ -254,7 +254,7 @@ Register getSrcRegIgnoringCopies(Register Reg, const MachineRegisterInfo &MRI);
template <class T>
T *getOpcodeDef(Register Reg, const MachineRegisterInfo &MRI) {
MachineInstr *DefMI = getDefIgnoringCopies(Reg, MRI);
- return dyn_cast_or_null<T>(DefMI);
+ return dyn_cast_if_present<T>(DefMI);
}
/// Returns an APFloat from Val converted to the appropriate size.
diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h
index f521862b1a54c2..c0cabf6927387d 100644
--- a/llvm/include/llvm/IR/DebugInfoMetadata.h
+++ b/llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -1066,7 +1066,7 @@ class DIDerivedType : public DIType {
DIType *getClassType() const;
DIObjCProperty *getObjCProperty() const {
- return dyn_cast_or_null<DIObjCProperty>(getExtraData());
+ return dyn_cast_if_present<DIObjCProperty>(getExtraData());
}
uint32_t getVBPtrOffset() const;
@@ -1244,33 +1244,33 @@ class DICompositeType : public DIType {
}
Metadata *getRawDataLocation() const { return getOperand(9); }
DIVariable *getDataLocation() const {
- return dyn_cast_or_null<DIVariable>(getRawDataLocation());
+ return dyn_cast_if_present<DIVariable>(getRawDataLocation());
}
DIExpression *getDataLocationExp() const {
- return dyn_cast_or_null<DIExpression>(getRawDataLocation());
+ return dyn_cast_if_present<DIExpression>(getRawDataLocation());
}
Metadata *getRawAssociated() const { return getOperand(10); }
DIVariable *getAssociated() const {
- return dyn_cast_or_null<DIVariable>(getRawAssociated());
+ return dyn_cast_if_present<DIVariable>(getRawAssociated());
}
DIExpression *getAssociatedExp() const {
- return dyn_cast_or_null<DIExpression>(getRawAssociated());
+ return dyn_cast_if_present<DIExpression>(getRawAssociated());
}
Metadata *getRawAllocated() const { return getOperand(11); }
DIVariable *getAllocated() const {
- return dyn_cast_or_null<DIVariable>(getRawAllocated());
+ return dyn_cast_if_present<DIVariable>(getRawAllocated());
}
DIExpression *getAllocatedExp() const {
- return dyn_cast_or_null<DIExpression>(getRawAllocated());
+ return dyn_cast_if_present<DIExpression>(getRawAllocated());
}
Metadata *getRawRank() const { return getOperand(12); }
ConstantInt *getRankConst() const {
- if (auto *MD = dyn_cast_or_null<ConstantAsMetadata>(getRawRank()))
- return dyn_cast_or_null<ConstantInt>(MD->getValue());
+ if (auto *MD = dyn_cast_if_present<ConstantAsMetadata>(getRawRank()))
+ return dyn_cast_if_present<ConstantInt>(MD->getValue());
return nullptr;
}
DIExpression *getRankExp() const {
- return dyn_cast_or_null<DIExpression>(getRawRank());
+ return dyn_cast_if_present<DIExpression>(getRawRank());
}
Metadata *getRawAnnotations() const { return getOperand(13); }
diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h
index 6eba902fa04165..e6ca678aecc951 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -1479,7 +1479,7 @@ class CallBase : public Instruction {
/// Returns the function called, or null if this is an indirect function
/// invocation or the function signature does not match the call signature.
Function *getCalledFunction() const {
- if (auto *F = dyn_cast_or_null<Function>(getCalledOperand()))
+ if (auto *F = dyn_cast_if_present<Function>(getCalledOperand()))
if (F->getValueType() == getFunctionType())
return F;
return nullptr;
diff --git a/llvm/include/llvm/IR/Metadata.h b/llvm/include/llvm/IR/Metadata.h
index 4498423c4c460d..8a727c9b7429f5 100644
--- a/llvm/include/llvm/IR/Metadata.h
+++ b/llvm/include/llvm/IR/Metadata.h
@@ -683,7 +683,7 @@ dyn_extract(Y &&MD) {
template <class X, class Y>
inline std::enable_if_t<detail::IsValidPointer<X, Y>::value, X *>
dyn_extract_or_null(Y &&MD) {
- if (auto *V = dyn_cast_or_null<ConstantAsMetadata>(MD))
+ if (auto *V = dyn_cast_if_present<ConstantAsMetadata>(MD))
return dyn_cast<X>(V->getValue());
return nullptr;
}
@@ -1539,11 +1539,11 @@ class AliasScopeNode {
const MDNode *getDomain() const {
if (Node->getNumOperands() < 2)
return nullptr;
- return dyn_cast_or_null<MDNode>(Node->getOperand(1));
+ return dyn_cast_if_present<MDNode>(Node->getOperand(1));
}
StringRef getName() const {
if (Node->getNumOperands() > 2)
- if (MDString *N = dyn_cast_or_null<MDString>(Node->getOperand(2)))
+ if (MDString *N = dyn_cast_if_present<MDString>(Node->getOperand(2)))
return N->getString();
return StringRef();
}
diff --git a/llvm/include/llvm/IR/PatternMatch.h b/llvm/include/llvm/IR/PatternMatch.h
index 096d1688af3f72..39c28d68dde5a7 100644
--- a/llvm/include/llvm/IR/PatternMatch.h
+++ b/llvm/include/llvm/IR/PatternMatch.h
@@ -239,8 +239,8 @@ struct apint_match {
}
if (V->getType()->isVectorTy())
if (const auto *C = dyn_cast<Constant>(V))
- if (auto *CI =
- dyn_cast_or_null<ConstantInt>(C->getSplatValue(AllowUndef))) {
+ if (auto *CI = dyn_cast_if_present<ConstantInt>(
+ C->getSplatValue(AllowUndef))) {
Res = &CI->getValue();
return true;
}
@@ -265,7 +265,7 @@ struct apfloat_match {
if (V->getType()->isVectorTy())
if (const auto *C = dyn_cast<Constant>(V))
if (auto *CI =
- dyn_cast_or_null<ConstantFP>(C->getSplatValue(AllowUndef))) {
+ dyn_cast_if_present<ConstantFP>(C->getSplatValue(AllowUndef))) {
Res = &CI->getValueAPF();
return true;
}
@@ -337,7 +337,8 @@ struct cstval_pred_ty : public Predicate {
return this->isValue(CV->getValue());
if (const auto *VTy = dyn_cast<VectorType>(V->getType())) {
if (const auto *C = dyn_cast<Constant>(V)) {
- if (const auto *CV = dyn_cast_or_null<ConstantVal>(C->getSplatValue()))
+ if (const auto *CV =
+ dyn_cast_if_present<ConstantVal>(C->getSplatValue()))
return this->isValue(CV->getValue());
// Number of elements of a scalable vector unknown at compile time
@@ -390,7 +391,7 @@ template <typename Predicate> struct api_pred_ty : public Predicate {
}
if (V->getType()->isVectorTy())
if (const auto *C = dyn_cast<Constant>(V))
- if (auto *CI = dyn_cast_or_null<ConstantInt>(C->getSplatValue()))
+ if (auto *CI = dyn_cast_if_present<ConstantInt>(C->getSplatValue()))
if (this->isValue(CI->getValue())) {
Res = &CI->getValue();
return true;
@@ -416,7 +417,7 @@ template <typename Predicate> struct apf_pred_ty : public Predicate {
}
if (V->getType()->isVectorTy())
if (const auto *C = dyn_cast<Constant>(V))
- if (auto *CI = dyn_cast_or_null<ConstantFP>(
+ if (auto *CI = dyn_cast_if_present<ConstantFP>(
C->getSplatValue(/* AllowUndef */ true)))
if (this->isValue(CI->getValue())) {
Res = &CI->getValue();
@@ -812,7 +813,7 @@ struct specific_fpval {
return CFP->isExactlyValue(Val);
if (V->getType()->isVectorTy())
if (const auto *C = dyn_cast<Constant>(V))
- if (auto *CFP = dyn_cast_or_null<ConstantFP>(C->getSplatValue()))
+ if (auto *CFP = dyn_cast_if_present<ConstantFP>(C->getSplatValue()))
return CFP->isExactlyValue(Val);
return false;
}
@@ -851,7 +852,7 @@ template <bool AllowUndefs> struct specific_intval {
const auto *CI = dyn_cast<ConstantInt>(V);
if (!CI && V->getType()->isVectorTy())
if (const auto *C = dyn_cast<Constant>(V))
- CI = dyn_cast_or_null<ConstantInt>(C->getSplatValue(AllowUndefs));
+ CI = dyn_cast_if_present<ConstantInt>(C->getSplatValue(AllowUndefs));
return CI && APInt::isSameValue(CI->getValue(), Val);
}
diff --git a/llvm/include/llvm/IR/Statepoint.h b/llvm/include/llvm/IR/Statepoint.h
index 21c4a3eaa5ac2d..97f26b00b617c8 100644
--- a/llvm/include/llvm/IR/Statepoint.h
+++ b/llvm/include/llvm/IR/Statepoint.h
@@ -114,7 +114,7 @@ class GCStatepointInst : public CallBase {
/// Returns the function called if this is a wrapping a direct call, and null
/// otherwise.
Function *getActualCalledFunction() const {
- return dyn_cast_or_null<Function>(getActualCalledOperand());
+ return dyn_cast_if_present<Function>(getActualCalledOperand());
}
/// Return the type of the value returned by the call underlying the
diff --git a/llvm/include/llvm/ProfileData/InstrProfReader.h b/llvm/include/llvm/ProfileData/InstrProfReader.h
index ff50dfde0e7938..9471963cfba2ee 100644
--- a/llvm/include/llvm/ProfileData/InstrProfReader.h
+++ b/llvm/include/llvm/ProfileData/InstrProfReader.h
@@ -349,7 +349,7 @@ class RawInstrProfReader : public InstrProfReader {
const InstrProfCorrelator *Correlator,
std::function<void(Error)> Warn)
: DataBuffer(std::move(DataBuffer)),
- Correlator(dyn_cast_or_null<const InstrProfCorrelatorImpl<IntPtrT>>(
+ Correlator(dyn_cast_if_present<const InstrProfCorrelatorImpl<IntPtrT>>(
Correlator)),
Warn(Warn) {}
RawInstrProfReader(const RawInstrProfReader &) = delete;
diff --git a/llvm/lib/Analysis/CallGraphSCCPass.cpp b/llvm/lib/Analysis/CallGraphSCCPass.cpp
index 307dddd51ece05..66ce1ea7e5c003 100644
--- a/llvm/lib/Analysis/CallGraphSCCPass.cpp
+++ b/llvm/lib/Analysis/CallGraphSCCPass.cpp
@@ -263,7 +263,7 @@ bool CGPassManager::RefreshCallGraph(const CallGraphSCC &CurSCC, CallGraph &CG,
// If this call site is null, then the function pass deleted the call
// entirely and the WeakTrackingVH nulled it out.
- auto *Call = dyn_cast_or_null<CallBase>(*I->first);
+ auto *Call = dyn_cast_if_present<CallBase>(*I->first);
if (!Call ||
// If we've already seen this call site, then the FunctionPass RAUW'd
// one call with another, which resulted in two "uses" in the edge
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 90da3390eab324..6b57fdf4e5c464 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -87,7 +87,7 @@ static Constant *foldConstVectorToAPInt(APInt &Result, Type *DestTy,
continue;
}
- auto *ElementCI = dyn_cast_or_null<ConstantInt>(Element);
+ auto *ElementCI = dyn_cast_if_present<ConstantInt>(Element);
if (!ElementCI)
return ConstantExpr::getBitCast(C, DestTy);
@@ -222,7 +222,7 @@ Constant *FoldBitCast(Constant *C, Type *DestTy, const DataLayout &DL) {
Src = Constant::getNullValue(
cast<VectorType>(C->getType())->getElementType());
else
- Src = dyn_cast_or_null<ConstantInt>(Src);
+ Src = dyn_cast_if_present<ConstantInt>(Src);
if (!Src) // Reject constantexpr elements.
return ConstantExpr::getBitCast(C, DestTy);
@@ -2490,7 +2490,7 @@ static Constant *ConstantFoldScalarCall1(StringRef Name,
case Intrinsic::x86_sse2_cvtsd2si:
case Intrinsic::x86_sse2_cvtsd2si64:
if (ConstantFP *FPOp =
- dyn_cast_or_null<ConstantFP>(Op->getAggregateElement(0U)))
+ dyn_cast_if_present<ConstantFP>(Op->getAggregateElement(0U)))
return ConstantFoldSSEConvertToInt(FPOp->getValueAPF(),
/*roundTowardZero=*/false, Ty,
/*IsSigned*/true);
@@ -2500,7 +2500,7 @@ static Constant *ConstantFoldScalarCall1(StringRef Name,
case Intrinsic::x86_sse2_cvttsd2si:
case Intrinsic::x86_sse2_cvttsd2si64:
if (ConstantFP *FPOp =
- dyn_cast_or_null<ConstantFP>(Op->getAggregateElement(0U)))
+ dyn_cast_if_present<ConstantFP>(Op->getAggregateElement(0U)))
return ConstantFoldSSEConvertToInt(FPOp->getValueAPF(),
/*roundTowardZero=*/true, Ty,
/*IsSigned*/true);
@@ -2882,7 +2882,7 @@ static Constant *ConstantFoldScalarCall2(StringRef Name,
case Intrinsic::x86_avx512_vcvtsd2si32:
case Intrinsic::x86_avx512_vcvtsd2si64:
if (ConstantFP *FPOp =
- dyn_cast_or_null<ConstantFP>(Op->getAggregateElement(0U)))
+ dyn_cast_if_present<ConstantFP>(Op->getAggregateElement(0U)))
return ConstantFoldSSEConvertToInt(FPOp->getValueAPF(),
/*roundTowardZero=*/false, Ty,
/*IsSigned*/true);
@@ -2892,7 +2892,7 @@ static Constant *ConstantFoldScalarCall2(StringRef Name,
case Intrinsic::x86_avx512_vcvtsd2usi32:
case Intrinsic::x86_avx512_vcvtsd2usi64:
if (ConstantFP *FPOp =
- dyn_cast_or_null<ConstantFP>(Op->getAggregateElement(0U)))
+ dyn_cast_if_present<ConstantFP>(Op->getAggregateElement(0U)))
return ConstantFoldSSEConvertToInt(FPOp->getValueAPF(),
/*roundTowardZero=*/false, Ty,
/*IsSigned*/false);
@@ -2902,7 +2902,7 @@ static Constant *ConstantFoldScalarCall2(StringRef Name,
case Intrinsic::x86_avx512_cvttsd2si:
case Intrinsic::x86_avx512_cvttsd2si64:
if (ConstantFP *FPOp =
- dyn_cast_or_null<ConstantFP>(Op->getAggregateElement(0U)))
+ dyn_cast_if_present<ConstantFP>(Op->getAggregateElement(0U)))
return ConstantFoldSSEConvertToInt(FPOp->getValueAPF(),
/*roundTowardZero=*/true, Ty,
/*IsSigned*/true);
@@ -2912,7 +2912,7 @@ static Constant *ConstantFoldScalarCall2(StringRef Name,
case Intrinsic::x86_avx512_cvttsd2usi:
case Intrinsic::x86_avx512_cvttsd2usi64:
if (ConstantFP *FPOp =
- dyn_cast_or_null<ConstantFP>(Op->getAggregateElement(0U)))
+ dyn_cast_if_present<ConstantFP>(Op->getAggregateElement(0U)))
return ConstantFoldSSEConvertToInt(FPOp->getValueAPF(),
/*roundTowardZero=*/true, Ty,
/*IsSigned*/false);
diff --git a/llvm/lib/Analysis/IVDescriptors.cpp b/llvm/lib/Analysis/IVDescriptors.cpp
index 1aa324c6b5f380..2c08425893aa54 100644
--- a/llvm/lib/Analysis/IVDescriptors.cpp
+++ b/llvm/lib/Analysis/IVDescriptors.cpp
@@ -974,7 +974,7 @@ bool RecurrenceDescriptor::isFixedOrderRecurrence(PHINode *Phi, Loop *TheLoop,
// in the header will be dominated by the original phi, but need to be moved
// after the non-phi previous value.
SmallPtrSet<PHINode *, 4> SeenPhis;
- while (auto *PrevPhi = dyn_cast_or_null<PHINode>(Previous)) {
+ while (auto *PrevPhi = dyn_cast_if_present<PHINode>(Previous)) {
if (PrevPhi->getParent() != Phi->getParent())
return false;
if (!SeenPhis.insert(PrevPhi).second)
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index 7096e06d925ade..e083430f18acfd 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -1458,7 +1458,7 @@ bool CallAnalyzer::visitAlloca(AllocaInst &I) {
// alloca and handle that case.
if (I.isArrayAllocation()) {
Constant *Size = SimplifiedValues.lookup(I.getArraySize());
- if (auto *AllocSize = dyn_cast_or_null<ConstantInt>(Size)) {
+ if (auto *AllocSize = dyn_cast_if_present<ConstantInt>(Size)) {
// Sometimes a dynamic alloca could be converted into a static alloca
// after this constant prop, and become a huge static alloca on an
// unconditional CFG path. Avoid inlining if this is going to happen above
@@ -1671,7 +1671,7 @@ bool CallAnalyzer::simplifyIntrinsicCallIsConstant(CallBase &CB) {
auto *C = dyn_cast<Constant>(Arg);
if (!C)
- C = dyn_cast_or_null<Constant>(SimplifiedValues.lookup(Arg));
+ C = dyn_cast_if_present<Constant>(SimplifiedValues.lookup(Arg));
Type *RT = CB.getFunctionType()->getReturnType();
SimplifiedValues[&CB] = ConstantInt::get(RT, C ? 1 : 0);
@@ -1686,7 +1686,7 @@ bool CallAnalyzer::simplifyIntrinsicCallObjectSize(CallBase &CB) {
Value *V = lowerObjectSizeCall(&cast<IntrinsicInst>(CB), DL, nullptr,
/*MustSucceed=*/true);
- Constant *C = dyn_cast_or_null<Constant>(V);
+ Constant *C = dyn_cast_if_present<Constant>(V);
if (C)
SimplifiedValues[&CB] = C;
return C;
@@ -2120,7 +2120,7 @@ bool CallAnalyzer::visitBinaryOperator(BinaryOperator &I) {
SimpleV =
simplifyBinOp(I.getOpcode(), CLHS ? CLHS : LHS, CRHS ? CRHS : RHS, DL);
- if (Constant *C = dyn_cast_or_null<Constant>(SimpleV))
+ if (Constant *C = dyn_cast_if_present<Constant>(SimpleV))
SimplifiedValues[&I] = C;
if (SimpleV)
@@ -2151,7 +2151,7 @@ bool CallAnalyzer::visitFNeg(UnaryOperator &I) {
Value *SimpleV = simplifyFNegInst(
COp ? COp : Op, cast<FPMathOperator>(I).getFastMathFlags(), DL);
- if (Constant *C = dyn_cast_or_null<Constant>(SimpleV))
+ if (Constant *C = dyn_cast_if_present<Constant>(SimpleV))
SimplifiedValues[&I] = C;
if (SimpleV)
@@ -2236,7 +2236,7 @@ bool CallAnalyzer::simplifyCallSite(Function *F, CallBase &Call) {
for (Value *I : Call.args()) {
Constant *C = dyn_cast<Constant>(I);
if (!C)
- C = dyn_cast_or_null<Constant>(SimplifiedValues.lookup(I));
+ C = dyn_cast_if_present<Constant>(SimplifiedValues.lookup(I));
if (!C)
return false; // This argument doesn't map to a constant.
@@ -2269,7 +2269,7 @@ bool CallAnalyzer::visitCallB...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/75733
More information about the llvm-commits
mailing list