diff options
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 25 |
5 files changed, 24 insertions, 18 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 1641c3e..c72b6e8 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -3194,7 +3194,7 @@ void AsmPrinter::emitJumpTableSizesSection(const MachineJumpTableInfo &MJTI, return; if (isElf) { - MCSymbolELF *LinkedToSym = dyn_cast<MCSymbolELF>(CurrentFnSym); + auto *LinkedToSym = static_cast<MCSymbolELF *>(CurrentFnSym); int Flags = F.hasComdat() ? static_cast<int>(ELF::SHF_GROUP) : 0; JumpTableSizesSection = OutContext.getELFSection( @@ -4702,7 +4702,7 @@ void AsmPrinter::emitXRayTable() { const Triple &TT = TM.getTargetTriple(); // Use PC-relative addresses on all targets. if (TT.isOSBinFormatELF()) { - auto LinkedToSym = cast<MCSymbolELF>(CurrentFnSym); + auto LinkedToSym = static_cast<const MCSymbolELF *>(CurrentFnSym); auto Flags = ELF::SHF_ALLOC | ELF::SHF_LINK_ORDER; StringRef GroupName; if (F.hasComdat()) { @@ -4825,7 +4825,7 @@ void AsmPrinter::emitPatchableFunctionEntries() { Flags |= ELF::SHF_GROUP; GroupName = F.getComdat()->getName(); } - LinkedToSym = cast<MCSymbolELF>(CurrentFnSym); + LinkedToSym = static_cast<const MCSymbolELF *>(CurrentFnSym); } OutStreamer->switchSection(OutContext.getELFSection( SectionName, ELF::SHT_PROGBITS, Flags, 0, GroupName, F.hasComdat(), diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index 5577a7d..f9d7e76 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -508,7 +508,8 @@ void DwarfCompileUnit::addWasmRelocBaseGlobal(DIELoc *Loc, StringRef GlobalName, // don't want to depend on target specific headers in this code? const unsigned TI_GLOBAL_RELOC = 3; unsigned PointerSize = Asm->getDataLayout().getPointerSize(); - auto *Sym = cast<MCSymbolWasm>(Asm->GetExternalSymbolSymbol(GlobalName)); + auto *Sym = + static_cast<MCSymbolWasm *>(Asm->GetExternalSymbolSymbol(GlobalName)); // FIXME: this repeats what WebAssemblyMCInstLower:: // GetExternalSymbolSymbol does, since if there's no code that // refers to this symbol, we have to set it here. diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index fd38c30..ab6fb30 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -2189,8 +2189,8 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID, unsigned Op = ID == Intrinsic::lifetime_start ? TargetOpcode::LIFETIME_START : TargetOpcode::LIFETIME_END; - const AllocaInst *AI = cast<AllocaInst>(CI.getArgOperand(1)); - if (!AI->isStaticAlloca()) + const AllocaInst *AI = dyn_cast<AllocaInst>(CI.getArgOperand(1)); + if (!AI || !AI->isStaticAlloca()) return true; MIRBuilder.buildInstr(Op).addFrameIndex(getOrCreateFrameIndex(*AI)); diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 306e068..ac0440f 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -7598,7 +7598,9 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, if (TM.getOptLevel() == CodeGenOptLevel::None) return; - const AllocaInst *LifetimeObject = cast<AllocaInst>(I.getArgOperand(1)); + const AllocaInst *LifetimeObject = dyn_cast<AllocaInst>(I.getArgOperand(1)); + if (!LifetimeObject) + return; // First check that the Alloca is static, otherwise it won't have a // valid frame index. diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index e9172f4..d19ef92 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -402,8 +402,8 @@ void TargetLoweringObjectFileELF::emitPersonalityValue( const MachineModuleInfo *MMI) const { SmallString<64> NameData("DW.ref."); NameData += Sym->getName(); - MCSymbolELF *Label = - cast<MCSymbolELF>(getContext().getOrCreateSymbol(NameData)); + auto *Label = + static_cast<MCSymbolELF *>(getContext().getOrCreateSymbol(NameData)); Streamer.emitSymbolAttribute(Label, MCSA_Hidden); Streamer.emitSymbolAttribute(Label, MCSA_Weak); unsigned Flags = ELF::SHF_ALLOC | ELF::SHF_WRITE | ELF::SHF_GROUP; @@ -581,7 +581,8 @@ static const MCSymbolELF *getLinkedToSymbol(const GlobalObject *GO, auto *VM = cast<ValueAsMetadata>(MD->getOperand(0).get()); auto *OtherGV = dyn_cast<GlobalValue>(VM->getValue()); - return OtherGV ? dyn_cast<MCSymbolELF>(TM.getSymbol(OtherGV)) : nullptr; + return OtherGV ? static_cast<const MCSymbolELF *>(TM.getSymbol(OtherGV)) + : nullptr; } static unsigned getEntrySizeForKind(SectionKind Kind) { @@ -1011,7 +1012,7 @@ MCSection *TargetLoweringObjectFileELF::getSectionForLSDA( (getContext().getAsmInfo()->useIntegratedAssembler() && getContext().getAsmInfo()->binutilsIsAtLeast(2, 36))) { Flags |= ELF::SHF_LINK_ORDER; - LinkedToSym = cast<MCSymbolELF>(&FnSym); + LinkedToSym = static_cast<const MCSymbolELF *>(&FnSym); } // Append the function name as the suffix like GCC, assuming @@ -2370,9 +2371,10 @@ bool TargetLoweringObjectFileXCOFF::ShouldSetSSPCanaryBitInTB( MCSymbol * TargetLoweringObjectFileXCOFF::getEHInfoTableSymbol(const MachineFunction *MF) { - MCSymbol *EHInfoSym = MF->getContext().getOrCreateSymbol( - "__ehinfo." + Twine(MF->getFunctionNumber())); - cast<MCSymbolXCOFF>(EHInfoSym)->setEHInfo(); + auto *EHInfoSym = + static_cast<MCSymbolXCOFF *>(MF->getContext().getOrCreateSymbol( + "__ehinfo." + Twine(MF->getFunctionNumber()))); + EHInfoSym->setEHInfo(); return EHInfoSym; } @@ -2510,7 +2512,8 @@ MCSection *TargetLoweringObjectFileXCOFF::SelectSectionForGlobal( if (Kind.isText()) { if (TM.getFunctionSections()) { - return cast<MCSymbolXCOFF>(getFunctionEntryPointSymbol(GO, TM)) + return static_cast<const MCSymbolXCOFF *>( + getFunctionEntryPointSymbol(GO, TM)) ->getRepresentedCsect(); } return TextSection; @@ -2713,7 +2716,7 @@ MCSection *TargetLoweringObjectFileXCOFF::getSectionForTOCEntry( const MCSymbol *Sym, const TargetMachine &TM) const { const XCOFF::StorageMappingClass SMC = [](const MCSymbol *Sym, const TargetMachine &TM) { - const MCSymbolXCOFF *XSym = cast<MCSymbolXCOFF>(Sym); + auto *XSym = static_cast<const MCSymbolXCOFF *>(Sym); // The "_$TLSML" symbol for TLS local-dynamic mode requires XMC_TC, // otherwise the AIX assembler will complain. @@ -2737,8 +2740,8 @@ MCSection *TargetLoweringObjectFileXCOFF::getSectionForTOCEntry( }(Sym, TM); return getContext().getXCOFFSection( - cast<MCSymbolXCOFF>(Sym)->getSymbolTableName(), SectionKind::getData(), - XCOFF::CsectProperties(SMC, XCOFF::XTY_SD)); + static_cast<const MCSymbolXCOFF *>(Sym)->getSymbolTableName(), + SectionKind::getData(), XCOFF::CsectProperties(SMC, XCOFF::XTY_SD)); } MCSection *TargetLoweringObjectFileXCOFF::getSectionForLSDA( |