[ThinLTO][Legacy] Fix StringRef assertion from ThinLTO bots
authorSteven Wu <stevenwu@apple.com>
Fri, 4 Sep 2020 19:25:01 +0000 (12:25 -0700)
committerSteven Wu <stevenwu@apple.com>
Fri, 4 Sep 2020 19:30:09 +0000 (12:30 -0700)
This is a presumed fix for FireFox thinLTO bot fix which hits assertion
failure for invalid index when access StringRef. Techinically, `IRName`
in the symtab should not be empty string for the entries we cared about
but this will help to fix the bot before more information can be
provided. Otherwise, NFCI.

llvm/lib/LTO/ThinLTOCodeGenerator.cpp

index 4adc9a2..14dae84 100644 (file)
@@ -276,7 +276,7 @@ static void computeGUIDPreservedSymbols(const lto::InputFile &File,
   // Iterate the symbols in the input file and if the input has preserved symbol
   // compute the GUID for the symbol.
   for (const auto &Sym : File.symbols()) {
-    if (PreservedSymbols.count(Sym.getName()))
+    if (PreservedSymbols.count(Sym.getName()) && !Sym.getIRName().empty())
       GUIDs.insert(GlobalValue::getGUID(GlobalValue::getGlobalIdentifier(
           Sym.getIRName(), GlobalValue::ExternalLinkage, "")));
   }