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
This commit is contained in:
Devang Patel 2008-07-16 18:06:52 +00:00
parent 0d885d1661
commit c2aec57c63
2 changed files with 40 additions and 0 deletions

View File

@ -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) {

View File

@ -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);