forked from OSchip/llvm-project
[Dwarf] Optimize getOrCreateSourceID() for repeated calls on same file (NFCI)
DwarfCompileUnit::getOrCreateSourceID() is often called many times in sequence with the same DIFile. This is currently very expensive, because it involves creating a string from directory and file name and looking it up in a string map. This patch remembers the last DIFile and its ID and directly returns that. This gives a geomean -1.3% compile-time improvement on CTMark O0-g. Differential Revision: https://reviews.llvm.org/D118041
This commit is contained in:
parent
70cb8daed4
commit
9554aaa275
|
@ -127,9 +127,14 @@ unsigned DwarfCompileUnit::getOrCreateSourceID(const DIFile *File) {
|
|||
if (!File)
|
||||
return Asm->OutStreamer->emitDwarfFileDirective(0, "", "", None, None,
|
||||
CUID);
|
||||
return Asm->OutStreamer->emitDwarfFileDirective(
|
||||
|
||||
if (LastFile != File) {
|
||||
LastFile = File;
|
||||
LastFileID = Asm->OutStreamer->emitDwarfFileDirective(
|
||||
0, File->getDirectory(), File->getFilename(), DD->getMD5AsBytes(File),
|
||||
File->getSource(), CUID);
|
||||
}
|
||||
return LastFileID;
|
||||
}
|
||||
|
||||
DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE(
|
||||
|
|
|
@ -86,6 +86,9 @@ class DwarfCompileUnit final : public DwarfUnit {
|
|||
/// DWO ID for correlating skeleton and split units.
|
||||
uint64_t DWOId = 0;
|
||||
|
||||
const DIFile *LastFile = nullptr;
|
||||
unsigned LastFileID;
|
||||
|
||||
/// Construct a DIE for the given DbgVariable without initializing the
|
||||
/// DbgVariable's DIE reference.
|
||||
DIE *constructVariableDIEImpl(const DbgVariable &DV, bool Abstract);
|
||||
|
|
Loading…
Reference in New Issue