[llvm-commits] [llvm] r69972 - in /llvm/trunk: include/llvm-c/lto.h tools/gold/gold-plugin.cpp tools/lto/LTOModule.cpp tools/lto/LTOModule.h
Rafael Espindola
rafael.espindola at gmail.com
Fri Apr 24 09:55:36 PDT 2009
Author: rafael
Date: Fri Apr 24 11:55:21 2009
New Revision: 69972
URL: http://llvm.org/viewvc/llvm-project?rev=69972&view=rev
Log:
Add LTO_SYMBOL_DEFINITION_WEAKUNDEF, use that on the gold plugin.
Modified:
llvm/trunk/include/llvm-c/lto.h
llvm/trunk/tools/gold/gold-plugin.cpp
llvm/trunk/tools/lto/LTOModule.cpp
llvm/trunk/tools/lto/LTOModule.h
Modified: llvm/trunk/include/llvm-c/lto.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/lto.h?rev=69972&r1=69971&r2=69972&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/lto.h (original)
+++ llvm/trunk/include/llvm-c/lto.h Fri Apr 24 11:55:21 2009
@@ -30,6 +30,7 @@
LTO_SYMBOL_DEFINITION_TENTATIVE = 0x00000200,
LTO_SYMBOL_DEFINITION_WEAK = 0x00000300,
LTO_SYMBOL_DEFINITION_UNDEFINED = 0x00000400,
+ LTO_SYMBOL_DEFINITION_WEAKUNDEF = 0x00000500,
LTO_SYMBOL_SCOPE_MASK = 0x00003800,
LTO_SYMBOL_SCOPE_INTERNAL = 0x00000800,
LTO_SYMBOL_SCOPE_HIDDEN = 0x00001000,
Modified: llvm/trunk/tools/gold/gold-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=69972&r1=69971&r2=69972&view=diff
==============================================================================
--- llvm/trunk/tools/gold/gold-plugin.cpp (original)
+++ llvm/trunk/tools/gold/gold-plugin.cpp Fri Apr 24 11:55:21 2009
@@ -257,6 +257,9 @@
case LTO_SYMBOL_DEFINITION_WEAK:
sym.def = LDPK_WEAKDEF;
break;
+ case LTO_SYMBOL_DEFINITION_WEAKUNDEF:
+ sym.def = LDPK_WEAKUNDEF;
+ break;
default:
(*message)(LDPL_ERROR, "Unknown definition attribute: %d", definition);
return LDPS_ERR;
Modified: llvm/trunk/tools/lto/LTOModule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.cpp?rev=69972&r1=69971&r2=69972&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOModule.cpp (original)
+++ llvm/trunk/tools/lto/LTOModule.cpp Fri Apr 24 11:55:21 2009
@@ -258,9 +258,21 @@
{
const char* name = mangler.getValueName(decl).c_str();
// ignore all llvm.* symbols
- if ( strncmp(name, "llvm.", 5) != 0 ) {
- _undefines[name] = 1;
- }
+ if ( strncmp(name, "llvm.", 5) == 0 )
+ return;
+
+ // we already have the symbol
+ if (_undefines.find(name) != _undefines.end())
+ return;
+
+ NameAndAttributes info;
+ // string is owned by _undefines
+ info.name = ::strdup(name);
+ if (decl->hasExternalWeakLinkage())
+ info.attributes = LTO_SYMBOL_DEFINITION_WEAKUNDEF;
+ else
+ info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED;
+ _undefines[name] = info;
}
@@ -339,16 +351,14 @@
}
// make symbols for all undefines
- for (StringSet::iterator it=_undefines.begin();
+ for (StringMap<NameAndAttributes>::iterator it=_undefines.begin();
it != _undefines.end(); ++it) {
// if this symbol also has a definition, then don't make an undefine
// because it is a tentative definition
if ( _defines.count(it->getKeyData(), it->getKeyData()+
it->getKeyLength()) == 0 ) {
- NameAndAttributes info;
- info.name = it->getKeyData();
- info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED;
- _symbols.push_back(info);
+ NameAndAttributes info = it->getValue();
+ _symbols.push_back(info);
}
}
}
Modified: llvm/trunk/tools/lto/LTOModule.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.h?rev=69972&r1=69971&r2=69972&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOModule.h (original)
+++ llvm/trunk/tools/lto/LTOModule.h Fri Apr 24 11:55:21 2009
@@ -97,7 +97,7 @@
std::vector<NameAndAttributes> _symbols;
// _defines and _undefines only needed to disambiguate tentative definitions
StringSet _defines;
- StringSet _undefines;
+ llvm::StringMap<NameAndAttributes> _undefines;
};
extern std::string getFeatureString(const char *TargetTriple);
More information about the llvm-commits
mailing list