X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FMC%2FMCContext.cpp;h=3c8de997124d950e8b9f4eeedea6bff76dc08f18;hb=8c987f534048928a7242e5edeac09b07de353a3d;hp=5c515b4f1eb5668685b5dae0555f5577e9b12f61;hpb=d0c33e548243e4320b917ad99376f34f5faf9546;p=oota-llvm.git diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp index 5c515b4f1eb..3c8de997124 100644 --- a/lib/MC/MCContext.cpp +++ b/lib/MC/MCContext.cpp @@ -84,14 +84,10 @@ void MCContext::reset() { Symbols.clear(); Allocator.Reset(); Instances.clear(); - MCDwarfFilesCUMap.clear(); - MCDwarfDirsCUMap.clear(); + MCDwarfFileTablesCUMap.clear(); MCGenDwarfLabelEntries.clear(); DwarfDebugFlags = StringRef(); - MCLineSections.clear(); - MCLineSectionOrder.clear(); DwarfCompileUnitID = 0; - MCLineTableSymbols.clear(); CurrentDwarfLoc = MCDwarfLoc(0,0,0,DWARF2_FLAG_IS_STMT,0,0); // If we have the MachO uniquing map, free it. @@ -166,32 +162,39 @@ MCSymbol *MCContext::CreateTempSymbol() { return CreateSymbol(NameSV); } -unsigned MCContext::NextInstance(int64_t LocalLabelVal) { +unsigned MCContext::NextInstance(unsigned LocalLabelVal) { MCLabel *&Label = Instances[LocalLabelVal]; if (!Label) Label = new (*this) MCLabel(0); return Label->incInstance(); } -unsigned MCContext::GetInstance(int64_t LocalLabelVal) { +unsigned MCContext::GetInstance(unsigned LocalLabelVal) { MCLabel *&Label = Instances[LocalLabelVal]; if (!Label) Label = new (*this) MCLabel(0); return Label->getInstance(); } -MCSymbol *MCContext::CreateDirectionalLocalSymbol(int64_t LocalLabelVal) { - return GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) + - Twine(LocalLabelVal) + - "\2" + - Twine(NextInstance(LocalLabelVal))); +MCSymbol *MCContext::getOrCreateDirectionalLocalSymbol(unsigned LocalLabelVal, + unsigned Instance) { + MCSymbol *&Sym = LocalSymbols[std::make_pair(LocalLabelVal, Instance)]; + if (!Sym) + Sym = CreateTempSymbol(); + return Sym; +} + +MCSymbol *MCContext::CreateDirectionalLocalSymbol(unsigned LocalLabelVal) { + unsigned Instance = NextInstance(LocalLabelVal); + return getOrCreateDirectionalLocalSymbol(LocalLabelVal, Instance); } -MCSymbol *MCContext::GetDirectionalLocalSymbol(int64_t LocalLabelVal, - int bORf) { - return GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) + - Twine(LocalLabelVal) + - "\2" + - Twine(GetInstance(LocalLabelVal) + bORf)); + +MCSymbol *MCContext::GetDirectionalLocalSymbol(unsigned LocalLabelVal, + bool Before) { + unsigned Instance = GetInstance(LocalLabelVal); + if (!Before) + ++Instance; + return getOrCreateDirectionalLocalSymbol(LocalLabelVal, Instance); } MCSymbol *MCContext::LookupSymbol(StringRef Name) const { @@ -334,24 +337,20 @@ const MCSectionCOFF *MCContext::getCOFFSection(StringRef Section) { /// allocated file number is returned. The file numbers may be in any order. unsigned MCContext::GetDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber, unsigned CUID) { - // TODO: a FileNumber of zero says to use the next available file number. - // Note: in GenericAsmParser::ParseDirectiveFile() FileNumber was checked - // to not be less than one. This needs to be change to be not less than zero. - - SmallVectorImpl& MCDwarfFiles = MCDwarfFilesCUMap[CUID]; - SmallVectorImpl& MCDwarfDirs = MCDwarfDirsCUMap[CUID]; + MCDwarfFileTable &Table = MCDwarfFileTablesCUMap[CUID]; + SmallVectorImpl& MCDwarfFiles = Table.getMCDwarfFiles(); + SmallVectorImpl& MCDwarfDirs = Table.getMCDwarfDirs(); // Make space for this FileNumber in the MCDwarfFiles vector if needed. if (FileNumber >= MCDwarfFiles.size()) { MCDwarfFiles.resize(FileNumber + 1); - } else { - MCDwarfFile *&ExistingFile = MCDwarfFiles[FileNumber]; - if (ExistingFile) - // It is an error to use see the same number more than once. - return 0; } // Get the new MCDwarfFile slot for this FileNumber. - MCDwarfFile *&File = MCDwarfFiles[FileNumber]; + MCDwarfFile &File = MCDwarfFiles[FileNumber]; + + // It is an error to use see the same number more than once. + if (!File.Name.empty()) + return 0; if (Directory.empty()) { // Separate the directory part from the basename of the FileName. @@ -387,11 +386,8 @@ unsigned MCContext::GetDwarfFile(StringRef Directory, StringRef FileName, DirIndex++; } - // Now make the MCDwarfFile entry and place it in the slot in the MCDwarfFiles - // vector. - char *Buf = static_cast(Allocate(FileName.size())); - memcpy(Buf, FileName.data(), FileName.size()); - File = new (*this) MCDwarfFile(StringRef(Buf, FileName.size()), DirIndex); + File.Name = FileName; + File.DirIndex = DirIndex; // return the allocated FileNumber. return FileNumber; @@ -400,11 +396,11 @@ unsigned MCContext::GetDwarfFile(StringRef Directory, StringRef FileName, /// isValidDwarfFileNumber - takes a dwarf file number and returns true if it /// currently is assigned and false otherwise. bool MCContext::isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID) { - SmallVectorImpl& MCDwarfFiles = MCDwarfFilesCUMap[CUID]; + const SmallVectorImpl& MCDwarfFiles = getMCDwarfFiles(CUID); if(FileNumber == 0 || FileNumber >= MCDwarfFiles.size()) return false; - return MCDwarfFiles[FileNumber] != 0; + return !MCDwarfFiles[FileNumber].Name.empty(); } void MCContext::FatalError(SMLoc Loc, const Twine &Msg) {