Copy symbol length when we replace a symbol.

Symbol's NameSize is computed lazily. Currently, when we replace a symbol,
a cached length value can be discarded. This patch propagates that value.

Differential Revision: https://reviews.llvm.org/D62234

llvm-svn: 361364
This commit is contained in:
Rui Ueyama 2019-05-22 09:19:30 +00:00
parent 091aaa69d3
commit ecf6eb515f
1 changed files with 5 additions and 0 deletions

View File

@ -486,6 +486,11 @@ void Symbol::replace(const Symbol &New) {
IsPreemptible = Old.IsPreemptible;
ScriptDefined = Old.ScriptDefined;
// Symbol length is computed lazily. If we already know a symbol length,
// propagate it.
if (NameData == Old.NameData && NameSize == 0 && Old.NameSize != 0)
NameSize = Old.NameSize;
// Print out a log message if --trace-symbol was specified.
// This is for debugging.
if (Traced)