diff options
author | Igor Kudrin <ikudrin@accesssoftek.com> | 2022-01-21 13:04:32 +0700 |
---|---|---|
committer | Igor Kudrin <ikudrin@accesssoftek.com> | 2022-01-21 13:52:10 +0700 |
commit | 75184f14aecd8147a02189a843789a4eb5e5b571 (patch) | |
tree | f4cb95d50118523bf271008d24b8b699ac519469 /llvm/lib/Support/TargetParser.cpp | |
parent | 8def89b5dc82efba039cca4ff9d072e169da7329 (diff) | |
download | llvm-75184f14aecd8147a02189a843789a4eb5e5b571.zip llvm-75184f14aecd8147a02189a843789a4eb5e5b571.tar.gz llvm-75184f14aecd8147a02189a843789a4eb5e5b571.tar.bz2 |
[DebugInfo] Fix handling '# line "file"' for DWARFv5
`CppHashInfo.Filename` is a `StringRef` that references a part of the
source file and it is not null-terminated at the end of the file name.
`AsmParser::parseAndMatchAndEmitTargetInstruction()` passes it to
`getStreamer().emitDwarfFileDirective()`, and it eventually comes to
`isRootFile()`. The comparison fails because `FileName.data()` is not
properly terminated.
In addition, the old code might cause a significant speed degradation
for long source files. The `operator!=()` for `std::string` and
`const char *` can be implemented in a way that it finds the length of
the second argument first, which slows the comparison for long data.
`parseAndMatchAndEmitTargetInstruction()` calls
`emitDwarfFileDirective()` every time if `CppHashInfo.Filename` is not
empty. As a result, the longer the source file is, the slower the
compilation wend, and for a very long file, it might take hours instead
of a couple of seconds normally.
Differential Revision: https://reviews.llvm.org/D117785
Diffstat (limited to 'llvm/lib/Support/TargetParser.cpp')
0 files changed, 0 insertions, 0 deletions