From 1fcbca05db736afc3e555aadc14ae3a5bef59198 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 2 Apr 2012 03:33:31 +0000 Subject: [PATCH] It could come about that we parse the inline ASM before we get a potential definition for it. In that case, we want to wait for the potential definition before we create a symbol for it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153859 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/lto/LTOModule.cpp | 26 ++++++++++++++++++++++++++ tools/lto/LTOModule.h | 1 + 2 files changed, 27 insertions(+) diff --git a/tools/lto/LTOModule.cpp b/tools/lto/LTOModule.cpp index fb66973357d..3bd764cb76a 100644 --- a/tools/lto/LTOModule.cpp +++ b/tools/lto/LTOModule.cpp @@ -399,6 +399,18 @@ void LTOModule::addAsmGlobalSymbol(const char *name, NameAndAttributes &info = _undefines[entry.getKey().data()]; + if (info.symbol == 0) { + // If we haven't seen this symbol before, save it and we may see it again. + StringMap::value_type + &asm_entry = _asm_defines.GetOrCreateValue(name); + NameAndAttributes &asm_info = _asm_defines[asm_entry.getKey().data()]; + asm_info.name = name; + asm_info.attributes = scope; + asm_info.isFunction = false; + asm_info.symbol = 0; + return; + } + if (info.isFunction) addDefinedFunctionSymbol(cast(info.symbol)); else @@ -452,6 +464,20 @@ void LTOModule::addPotentialUndefinedSymbol(GlobalValue *decl, bool isFunc) { if (entry.getValue().name) return; + StringMap::value_type &asm_entry = + _asm_defines.GetOrCreateValue(name); + + if (asm_entry.getValue().name != 0) { + if (isFunc) + addDefinedFunctionSymbol(cast(decl)); + else + addDefinedDataSymbol(decl); + + _symbols.back().attributes &= ~LTO_SYMBOL_SCOPE_MASK; + _symbols.back().attributes |= asm_entry.getValue().attributes; + return; + } + NameAndAttributes info; info.name = entry.getKey().data(); diff --git a/tools/lto/LTOModule.h b/tools/lto/LTOModule.h index cafb927abfb..6280c6770d2 100644 --- a/tools/lto/LTOModule.h +++ b/tools/lto/LTOModule.h @@ -53,6 +53,7 @@ private: // _defines and _undefines only needed to disambiguate tentative definitions StringSet _defines; llvm::StringMap _undefines; + llvm::StringMap _asm_defines; std::vector _asm_undefines; llvm::MCContext _context; -- 2.34.1