-void Mangler::InsertName(GlobalValue *GV,
- std::map<std::string, GlobalValue*> &Names) {
- if (!GV->hasName()) { // We must mangle unnamed globals.
- MangledGlobals.insert(GV);
- return;
- }
-
- // Figure out if this is already used.
- GlobalValue *&ExistingValue = Names[GV->getName()];
- if (!ExistingValue) {
- ExistingValue = GV;
- } else {
- // If GV is external but the existing one is static, mangle the existing one
- if (GV->hasExternalLinkage() && !ExistingValue->hasExternalLinkage()) {
- MangledGlobals.insert(ExistingValue);
- ExistingValue = GV;
- } else {
- // Otherwise, mangle GV
- MangledGlobals.insert(GV);
- }
- }
-}
-
-
-Mangler::Mangler(Module &M, const char *prefix)
- : Prefix(prefix), UseQuotes(false), Count(0), TypeCounter(0) {
- std::fill(AcceptableChars,
- AcceptableChars+sizeof(AcceptableChars)/sizeof(AcceptableChars[0]),
- 0);
+Mangler::Mangler(Module &M, const char *prefix, const char *privatePrefix)
+ : Prefix(prefix), PrivatePrefix (privatePrefix), UseQuotes(false),
+ PreserveAsmNames(false), Count(0), TypeCounter(0) {
+ std::fill(AcceptableChars, array_endof(AcceptableChars), 0);