[llvm-commits] [llvm] r75556 - in /llvm/trunk/lib/Target: CBackend/CBackend.cpp MSIL/MSILWriter.cpp MSIL/MSILWriter.h
Chris Lattner
sabre at nondot.org
Mon Jul 13 16:46:47 PDT 2009
Author: lattner
Date: Mon Jul 13 18:46:46 2009
New Revision: 75556
URL: http://llvm.org/viewvc/llvm-project?rev=75556&view=rev
Log:
fix CBE & MSIL backends to not use the mangler for non-global symbols.
Modified:
llvm/trunk/lib/Target/CBackend/CBackend.cpp
llvm/trunk/lib/Target/MSIL/MSILWriter.cpp
llvm/trunk/lib/Target/MSIL/MSILWriter.h
Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=75556&r1=75555&r2=75556&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original)
+++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Mon Jul 13 18:46:46 2009
@@ -102,12 +102,14 @@
std::set<const Argument*> ByValParams;
unsigned FPCounter;
unsigned OpaqueCounter;
+ DenseMap<const Value*, unsigned> AnonValueNumbers;
+ unsigned NextAnonValueNumber;
public:
static char ID;
explicit CWriter(raw_ostream &o)
: FunctionPass(&ID), Out(o), IL(0), Mang(0), LI(0),
- TheModule(0), TAsm(0), TD(0), OpaqueCounter(0) {
+ TheModule(0), TAsm(0), TD(0), OpaqueCounter(0), NextAnonValueNumber(0) {
FPCounter = 0;
}
@@ -1428,33 +1430,36 @@
}
std::string CWriter::GetValueName(const Value *Operand) {
- std::string Name;
-
- if (!isa<GlobalValue>(Operand) && Operand->getName() != "") {
- std::string VarName;
-
- Name = Operand->getName();
- VarName.reserve(Name.capacity());
-
- for (std::string::iterator I = Name.begin(), E = Name.end();
- I != E; ++I) {
- char ch = *I;
+ // Mangle globals with the standard mangler interface for LLC compatibility.
+ if (const GlobalValue *GV = dyn_cast<GlobalValue>(Operand))
+ return Mang->getValueName(GV);
+
+ std::string Name = Operand->getName();
+
+ if (Name.empty()) { // Assign unique names to local temporaries.
+ unsigned &No = AnonValueNumbers[Operand];
+ if (No == 0)
+ No = ++NextAnonValueNumber;
+ Name = "tmp__" + utostr(No);
+ }
+
+ std::string VarName;
+ VarName.reserve(Name.capacity());
- if (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') ||
- (ch >= '0' && ch <= '9') || ch == '_')) {
- char buffer[5];
- sprintf(buffer, "_%x_", ch);
- VarName += buffer;
- } else
- VarName += ch;
- }
+ for (std::string::iterator I = Name.begin(), E = Name.end();
+ I != E; ++I) {
+ char ch = *I;
- Name = "llvm_cbe_" + VarName;
- } else {
- Name = Mang->getValueName(Operand);
+ if (!((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') ||
+ (ch >= '0' && ch <= '9') || ch == '_')) {
+ char buffer[5];
+ sprintf(buffer, "_%x_", ch);
+ VarName += buffer;
+ } else
+ VarName += ch;
}
- return Name;
+ return "llvm_cbe_" + VarName;
}
/// writeInstComputationInline - Emit the computation for the specified
Modified: llvm/trunk/lib/Target/MSIL/MSILWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSIL/MSILWriter.cpp?rev=75556&r1=75555&r2=75556&view=diff
==============================================================================
--- llvm/trunk/lib/Target/MSIL/MSILWriter.cpp (original)
+++ llvm/trunk/lib/Target/MSIL/MSILWriter.cpp Mon Jul 13 18:46:46 2009
@@ -240,8 +240,17 @@
std::string MSILWriter::getValueName(const Value* V) {
+ std::string Name;
+ if (const GlobalValue *GV = cast<GlobalValue>(V))
+ Name = Mang->getValueName(GV);
+ else {
+ unsigned &No = AnonValueNumbers[V];
+ if (No == 0) No = ++NextAnonValueNumber;
+ Name = "tmp" + utostr(No);
+ }
+
// Name into the quotes allow control and space characters.
- return "'"+Mang->getValueName(V)+"'";
+ return "'"+Name+"'";
}
@@ -258,7 +267,16 @@
std::string MSILWriter::getLabelName(const Value* V) {
- return getLabelName(Mang->getValueName(V));
+ std::string Name;
+ if (const GlobalValue *GV = cast<GlobalValue>(V))
+ Name = Mang->getValueName(GV);
+ else {
+ unsigned &No = AnonValueNumbers[V];
+ if (No == 0) No = ++NextAnonValueNumber;
+ Name = "tmp" + utostr(No);
+ }
+
+ return getLabelName(Name);
}
Modified: llvm/trunk/lib/Target/MSIL/MSILWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSIL/MSILWriter.h?rev=75556&r1=75555&r2=75556&view=diff
==============================================================================
--- llvm/trunk/lib/Target/MSIL/MSILWriter.h (original)
+++ llvm/trunk/lib/Target/MSIL/MSILWriter.h Mon Jul 13 18:46:46 2009
@@ -85,7 +85,11 @@
StaticInitList;
const std::set<const Type *>* UsedTypes;
static char ID;
- MSILWriter(raw_ostream &o) : FunctionPass(&ID), Out(o) {
+ DenseMap<const Value*, unsigned> AnonValueNumbers;
+ unsigned NextAnonValueNumber;
+
+ MSILWriter(raw_ostream &o)
+ : FunctionPass(&ID), Out(o), NextAnonValueNumber(0) {
UniqID = 0;
}
More information about the llvm-commits
mailing list