void MachineFunction::tidyLandingPads(DenseMap<MCSymbol*, uintptr_t> *LPMap) { for (unsigned i = 0; i != LandingPads.size(); ) { LandingPadInfo &LandingPad = LandingPads[i]; if (LandingPad.LandingPadLabel && !LandingPad.LandingPadLabel->isDefined() && (!LPMap || (*LPMap)[LandingPad.LandingPadLabel] == 0)) LandingPad.LandingPadLabel = nullptr; // Special case: we *should* emit LPs with null LP MBB. This indicates // "nounwind" case. if (!LandingPad.LandingPadLabel && LandingPad.LandingPadBlock) { LandingPads.erase(LandingPads.begin() + i); continue; } for (unsigned j = 0, e = LandingPads[i].BeginLabels.size(); j != e; ++j) { MCSymbol *BeginLabel = LandingPad.BeginLabels[j]; MCSymbol *EndLabel = LandingPad.EndLabels[j]; if ((BeginLabel->isDefined() || (LPMap && (*LPMap)[BeginLabel] != 0)) && (EndLabel->isDefined() || (LPMap && (*LPMap)[EndLabel] != 0))) continue; LandingPad.BeginLabels.erase(LandingPad.BeginLabels.begin() + j); LandingPad.EndLabels.erase(LandingPad.EndLabels.begin() + j); --j; --e; } // Remove landing pads with no try-ranges. if (LandingPads[i].BeginLabels.empty()) { LandingPads.erase(LandingPads.begin() + i); continue; } // If there is no landing pad, ensure that the list of typeids is empty. // If the only typeid is a cleanup, this is the same as having no typeids. if (!LandingPad.LandingPadBlock || (LandingPad.TypeIds.size() == 1 && !LandingPad.TypeIds[0])) LandingPad.TypeIds.clear(); ++i; } }
uint32_t SVMMemoryLayout::getEntryAddress(const MCAssembler &Asm, const MCAsmLayout &Layout) const { MCSymbol *S = Asm.getContext().LookupSymbol("main"); if (!S || !S->isDefined()) report_fatal_error("No entry point exists. Is main() defined?"); SVMSymbolInfo SI = getSymbol(Asm, Layout, S); assert(SI.Kind == SVMSymbolInfo::LOCAL); return SI.Value; }
/// parseDirectiveAltEntry /// ::= .alt_entry identifier bool DarwinAsmParser::parseDirectiveAltEntry(StringRef, SMLoc) { StringRef Name; if (getParser().parseIdentifier(Name)) return TokError("expected identifier in directive"); // Look up symbol. MCSymbol *Sym = getContext().getOrCreateSymbol(Name); if (Sym->isDefined()) return TokError(".alt_entry must preceed symbol definition"); if (!getStreamer().EmitSymbolAttribute(Sym, MCSA_AltEntry)) return TokError("unable to emit symbol attribute"); Lex(); return false; }
void MMIAddrLabelMap::UpdateForDeletedBlock(BasicBlock *BB) { // If the block got deleted, there is no need for the symbol. If the symbol // was already emitted, we can just forget about it, otherwise we need to // queue it up for later emission when the function is output. AddrLabelSymEntry Entry = AddrLabelSymbols[BB]; AddrLabelSymbols.erase(BB); assert(!Entry.Symbols.isNull() && "Didn't have a symbol, why a callback?"); BBCallbacks[Entry.Index] = nullptr; // Clear the callback. assert((BB->getParent() == nullptr || BB->getParent() == Entry.Fn) && "Block/parent mismatch"); // Handle both the single and the multiple symbols cases. if (MCSymbol *Sym = Entry.Symbols.dyn_cast<MCSymbol*>()) { if (Sym->isDefined()) return; // If the block is not yet defined, we need to emit it at the end of the // function. Add the symbol to the DeletedAddrLabelsNeedingEmission list // for the containing Function. Since the block is being deleted, its // parent may already be removed, we have to get the function from 'Entry'. DeletedAddrLabelsNeedingEmission[Entry.Fn].push_back(Sym); } else { std::vector<MCSymbol*> *Syms = Entry.Symbols.get<std::vector<MCSymbol*>*>(); for (unsigned i = 0, e = Syms->size(); i != e; ++i) { MCSymbol *Sym = (*Syms)[i]; if (Sym->isDefined()) continue; // Ignore already emitted labels. // If the block is not yet defined, we need to emit it at the end of the // function. Add the symbol to the DeletedAddrLabelsNeedingEmission list // for the containing Function. Since the block is being deleted, its // parent may already be removed, we have to get the function from // 'Entry'. DeletedAddrLabelsNeedingEmission[Entry.Fn].push_back(Sym); } // The entry is deleted, free the memory associated with the symbol list. delete Syms; } }
/// EmitFrameMoves - Emit frame instructions to describe the layout of the /// frame. void AsmPrinter::EmitFrameMoves(const std::vector<MachineMove> &Moves, MCSymbol *BaseLabel, bool isEH) const { const TargetRegisterInfo *RI = TM.getRegisterInfo(); int stackGrowth = TM.getTargetData()->getPointerSize(); if (TM.getFrameInfo()->getStackGrowthDirection() != TargetFrameInfo::StackGrowsUp) stackGrowth *= -1; for (unsigned i = 0, N = Moves.size(); i < N; ++i) { const MachineMove &Move = Moves[i]; MCSymbol *Label = Move.getLabel(); // Throw out move if the label is invalid. if (Label && !Label->isDefined()) continue; // Not emitted, in dead code. const MachineLocation &Dst = Move.getDestination(); const MachineLocation &Src = Move.getSource(); // Advance row if new location. if (BaseLabel && Label) { MCSymbol *ThisSym = Label; if (ThisSym != BaseLabel) { EmitCFAByte(dwarf::DW_CFA_advance_loc4); EmitLabelDifference(ThisSym, BaseLabel, 4); BaseLabel = ThisSym; } } // If advancing cfa. if (Dst.isReg() && Dst.getReg() == MachineLocation::VirtualFP) { assert(!Src.isReg() && "Machine move not supported yet."); if (Src.getReg() == MachineLocation::VirtualFP) { EmitCFAByte(dwarf::DW_CFA_def_cfa_offset); } else { EmitCFAByte(dwarf::DW_CFA_def_cfa); EmitULEB128(RI->getDwarfRegNum(Src.getReg(), isEH), "Register"); } EmitULEB128(-Src.getOffset(), "Offset"); continue; } if (Src.isReg() && Src.getReg() == MachineLocation::VirtualFP) { assert(Dst.isReg() && "Machine move not supported yet."); EmitCFAByte(dwarf::DW_CFA_def_cfa_register); EmitULEB128(RI->getDwarfRegNum(Dst.getReg(), isEH), "Register"); continue; } unsigned Reg = RI->getDwarfRegNum(Src.getReg(), isEH); int Offset = Dst.getOffset() / stackGrowth; if (Offset < 0) { EmitCFAByte(dwarf::DW_CFA_offset_extended_sf); EmitULEB128(Reg, "Reg"); EmitSLEB128(Offset, "Offset"); } else if (Reg < 64) { EmitCFAByte(dwarf::DW_CFA_offset + Reg); EmitULEB128(Offset, "Offset"); } else { EmitCFAByte(dwarf::DW_CFA_offset_extended); EmitULEB128(Reg, "Reg"); EmitULEB128(Offset, "Offset"); } } }