[llvm-commits] [llvm] r53693 - in /llvm/trunk/tools/lto: LTOModule.cpp LTOModule.h
Devang Patel
dpatel at apple.com
Wed Jul 16 11:06:53 PDT 2008
Author: dpatel
Date: Wed Jul 16 13:06:52 2008
New Revision: 53693
URL: http://llvm.org/viewvc/llvm-project?rev=53693&view=rev
Log:
Do not forget global definitions from inline asm code block.
Modified:
llvm/trunk/tools/lto/LTOModule.cpp
llvm/trunk/tools/lto/LTOModule.h
Modified: llvm/trunk/tools/lto/LTOModule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.cpp?rev=53693&r1=53692&r2=53693&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOModule.cpp (original)
+++ llvm/trunk/tools/lto/LTOModule.cpp Wed Jul 16 13:06:52 2008
@@ -238,6 +238,19 @@
_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 @@
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) {
Modified: llvm/trunk/tools/lto/LTOModule.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.h?rev=53693&r1=53692&r2=53693&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOModule.h (original)
+++ llvm/trunk/tools/lto/LTOModule.h Wed Jul 16 13:06:52 2008
@@ -76,6 +76,7 @@
llvm::Mangler &mangler);
void addDefinedDataSymbol(llvm::GlobalValue* v,
llvm::Mangler &mangler);
+ void addAsmGlobalSymbol(const char *);
static bool isTargetMatch(llvm::MemoryBuffer* memBuffer,
const char* triplePrefix);
More information about the llvm-commits
mailing list