[llvm-commits] CVS: llvm/lib/VMCore/Mangler.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Nov 14 17:32:14 PST 2005
Changes in directory llvm/lib/VMCore:
Mangler.cpp updated: 1.25 -> 1.26
---
Log message:
Fix handling of multiple unnamed globals with the same type
---
Diffs of the changes: (+6 -3)
Mangler.cpp | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
Index: llvm/lib/VMCore/Mangler.cpp
diff -u llvm/lib/VMCore/Mangler.cpp:1.25 llvm/lib/VMCore/Mangler.cpp:1.26
--- llvm/lib/VMCore/Mangler.cpp:1.25 Thu Nov 10 17:24:26 2005
+++ llvm/lib/VMCore/Mangler.cpp Mon Nov 14 19:32:03 2005
@@ -132,6 +132,11 @@
// - Otherwise, mangling occurs if global collides with existing name.
if (isa<Function>(GV) && cast<Function>(GV)->getIntrinsicID()) {
Name = GV->getName(); // Is an intrinsic function
+ } else if (!GV->hasName()) {
+ // Must mangle the global into a unique ID.
+ unsigned TypeUniqueID = getTypeID(GV->getType());
+ static unsigned GlobalID = 0;
+ Name = "__unnamed_" + utostr(TypeUniqueID) + "_" + utostr(GlobalID++);
} else if (!MangledGlobals.count(GV)) {
Name = makeNameProper(GV->getName(), Prefix);
} else {
@@ -144,10 +149,8 @@
void Mangler::InsertName(GlobalValue *GV,
std::map<std::string, GlobalValue*> &Names) {
- if (!GV->hasName()) { // We must mangle unnamed globals.
- MangledGlobals.insert(GV);
+ if (!GV->hasName()) // We must mangle unnamed globals.
return;
- }
// Figure out if this is already used.
GlobalValue *&ExistingValue = Names[GV->getName()];
More information about the llvm-commits
mailing list