llvm.org GIT mirror llvm / c2aec57
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 Devang Patel 11 years ago
2 changed file(s) with 40 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
237237 _defines[info.name] = 1;
238238 }
239239
240 void LTOModule::addAsmGlobalSymbol(const char *name) {
241 // string is owned by _defines
242 const char *symbolName = ::strdup(name);
243 uint32_t attr = LTO_SYMBOL_DEFINITION_REGULAR;
244 attr |= LTO_SYMBOL_SCOPE_DEFAULT;
245
246 // add to table of symbols
247 NameAndAttributes info;
248 info.name = symbolName;
249 info.attributes = (lto_symbol_attributes)attr;
250 _symbols.push_back(info);
251 _defines[info.name] = 1;
252 }
240253
241254 void LTOModule::addPotentialUndefinedSymbol(GlobalValue* decl, Mangler &mangler)
242255 {
294307 addPotentialUndefinedSymbol(v, mangler);
295308 else
296309 addDefinedDataSymbol(v, mangler);
310 }
311
312 // add asm globals
313 const std::string &inlineAsm = _module->getModuleInlineAsm();
314 const std::string glbl = ".globl";
315 std::string asmSymbolName;
316 std::string::size_type pos = inlineAsm.find(glbl, 0);
317 while (pos != std::string::npos) {
318 // eat .globl
319 pos = pos + 6;
320
321 // skip white space between .globl and symbol name
322 std::string::size_type pbegin = inlineAsm.find_first_not_of(' ', pos);
323 if (pbegin == std::string::npos)
324 break;
325
326 // find end-of-line
327 std::string::size_type pend = inlineAsm.find_first_of('\n', pbegin);
328 if (pend == std::string::npos)
329 break;
330
331 asmSymbolName.assign(inlineAsm, pbegin, pbegin-pend);
332 addAsmGlobalSymbol(asmSymbolName.c_str());
333
334 // search next .globl
335 pos = inlineAsm.find(glbl, pend);
297336 }
298337
299338 // make symbols for all undefines
7575 llvm::Mangler &mangler);
7676 void addDefinedDataSymbol(llvm::GlobalValue* v,
7777 llvm::Mangler &mangler);
78 void addAsmGlobalSymbol(const char *);
7879 static bool isTargetMatch(llvm::MemoryBuffer* memBuffer,
7980 const char* triplePrefix);
8081