diff options
author | Devang Patel <dpatel@apple.com> | 2008-07-16 18:06:52 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2008-07-16 18:06:52 +0000 |
commit | c2aec57c63a8551cef27025dc7f0d2d9e56db013 (patch) | |
tree | 47bcdd9ab273156d8f12047ab6f78ae04b6da48e | |
parent | 0d885d1661f87bd2dc25bfdacb29413f0be81bd4 (diff) | |
download | external_llvm-c2aec57c63a8551cef27025dc7f0d2d9e56db013.zip external_llvm-c2aec57c63a8551cef27025dc7f0d2d9e56db013.tar.gz external_llvm-c2aec57c63a8551cef27025dc7f0d2d9e56db013.tar.bz2 |
Do not forget global definitions from inline asm code block.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53693 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | tools/lto/LTOModule.cpp | 39 | ||||
-rw-r--r-- | tools/lto/LTOModule.h | 1 |
2 files changed, 40 insertions, 0 deletions
diff --git a/tools/lto/LTOModule.cpp b/tools/lto/LTOModule.cpp index f31f0df..ac38d24 100644 --- a/tools/lto/LTOModule.cpp +++ b/tools/lto/LTOModule.cpp @@ -238,6 +238,19 @@ void LTOModule::addDefinedSymbol(GlobalValue* def, Mangler &mangler, _defines[info.name] = 1; } +void LTOModule::addAsmGlobalSymbol(const char *name) { + // string is owned by _defines + const char *symbolName = ::strdup(name); + uint32_t attr = LTO_SYMBOL_DEFINITION_REGULAR; + attr |= LTO_SYMBOL_SCOPE_DEFAULT; + + // add to table of symbols + NameAndAttributes info; + info.name = symbolName; + info.attributes = (lto_symbol_attributes)attr; + _symbols.push_back(info); + _defines[info.name] = 1; +} void LTOModule::addPotentialUndefinedSymbol(GlobalValue* decl, Mangler &mangler) { @@ -297,6 +310,32 @@ void LTOModule::lazyParseSymbols() addDefinedDataSymbol(v, mangler); } + // add asm globals + const std::string &inlineAsm = _module->getModuleInlineAsm(); + const std::string glbl = ".globl"; + std::string asmSymbolName; + std::string::size_type pos = inlineAsm.find(glbl, 0); + while (pos != std::string::npos) { + // eat .globl + pos = pos + 6; + + // skip white space between .globl and symbol name + std::string::size_type pbegin = inlineAsm.find_first_not_of(' ', pos); + if (pbegin == std::string::npos) + break; + + // find end-of-line + std::string::size_type pend = inlineAsm.find_first_of('\n', pbegin); + if (pend == std::string::npos) + break; + + asmSymbolName.assign(inlineAsm, pbegin, pbegin-pend); + addAsmGlobalSymbol(asmSymbolName.c_str()); + + // search next .globl + pos = inlineAsm.find(glbl, pend); + } + // make symbols for all undefines for (StringSet::iterator it=_undefines.begin(); it != _undefines.end(); ++it) { diff --git a/tools/lto/LTOModule.h b/tools/lto/LTOModule.h index 40f92f9..0cb9cdc 100644 --- a/tools/lto/LTOModule.h +++ b/tools/lto/LTOModule.h @@ -76,6 +76,7 @@ private: llvm::Mangler &mangler); void addDefinedDataSymbol(llvm::GlobalValue* v, llvm::Mangler &mangler); + void addAsmGlobalSymbol(const char *); static bool isTargetMatch(llvm::MemoryBuffer* memBuffer, const char* triplePrefix); |