[llvm-commits] [llvm] r153859 - in /llvm/trunk/tools/lto: LTOModule.cpp LTOModule.h

Bill Wendling isanbard at gmail.com
Sun Apr 1 20:33:31 PDT 2012


Author: void
Date: Sun Apr  1 22:33:31 2012
New Revision: 153859

URL: http://llvm.org/viewvc/llvm-project?rev=153859&view=rev
Log:
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.

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=153859&r1=153858&r2=153859&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOModule.cpp (original)
+++ llvm/trunk/tools/lto/LTOModule.cpp Sun Apr  1 22:33:31 2012
@@ -399,6 +399,18 @@
 
   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<NameAndAttributes>::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<Function>(info.symbol));
   else
@@ -452,6 +464,20 @@
   if (entry.getValue().name)
     return;
 
+  StringMap<NameAndAttributes>::value_type &asm_entry =
+    _asm_defines.GetOrCreateValue(name);
+
+  if (asm_entry.getValue().name != 0) {
+    if (isFunc)
+      addDefinedFunctionSymbol(cast<Function>(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();

Modified: llvm/trunk/tools/lto/LTOModule.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.h?rev=153859&r1=153858&r2=153859&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOModule.h (original)
+++ llvm/trunk/tools/lto/LTOModule.h Sun Apr  1 22:33:31 2012
@@ -53,6 +53,7 @@
   // _defines and _undefines only needed to disambiguate tentative definitions
   StringSet                               _defines;
   llvm::StringMap<NameAndAttributes>      _undefines;
+  llvm::StringMap<NameAndAttributes>      _asm_defines;
   std::vector<const char*>                _asm_undefines;
   llvm::MCContext                         _context;
 





More information about the llvm-commits mailing list