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.
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 {
/// 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<MCDwarfFile *>& MCDwarfFiles = MCDwarfFilesCUMap[CUID];
- SmallVectorImpl<StringRef>& MCDwarfDirs = MCDwarfDirsCUMap[CUID];
+ MCDwarfFileTable &Table = MCDwarfFileTablesCUMap[CUID];
+ SmallVectorImpl<MCDwarfFile>& MCDwarfFiles = Table.getMCDwarfFiles();
+ SmallVectorImpl<StringRef>& 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.
DirIndex++;
}
- // Now make the MCDwarfFile entry and place it in the slot in the MCDwarfFiles
- // vector.
- char *Buf = static_cast<char *>(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;
/// 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<MCDwarfFile *>& MCDwarfFiles = MCDwarfFilesCUMap[CUID];
+ const SmallVectorImpl<MCDwarfFile>& 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) {