[llvm-commits] CVS: llvm/lib/Target/CBackend/CBackend.cpp
Chris Lattner
sabre at nondot.org
Mon Jan 15 23:22:39 PST 2007
Changes in directory llvm/lib/Target/CBackend:
CBackend.cpp updated: 1.317 -> 1.318
---
Log message:
Fix PR918: http://llvm.org/PR918 by only using typedefs to name struct types. This makes the later
type ordering stuff work better. This fixes PR918: http://llvm.org/PR918 and
CodeGen/CBackend/2007-01-15-NamedArrayType.ll
Patch by Gordon Henriksen.
---
Diffs of the changes: (+15 -8)
CBackend.cpp | 23 +++++++++++++++--------
1 files changed, 15 insertions(+), 8 deletions(-)
Index: llvm/lib/Target/CBackend/CBackend.cpp
diff -u llvm/lib/Target/CBackend/CBackend.cpp:1.317 llvm/lib/Target/CBackend/CBackend.cpp:1.318
--- llvm/lib/Target/CBackend/CBackend.cpp:1.317 Sun Jan 14 20:27:26 2007
+++ llvm/lib/Target/CBackend/CBackend.cpp Tue Jan 16 01:22:23 2007
@@ -269,13 +269,19 @@
for (TypeSymbolTable::iterator TI = TST.begin(), TE = TST.end();
TI != TE; ) {
TypeSymbolTable::iterator I = TI++;
-
- // If this is not used, remove it from the symbol table.
- std::set<const Type *>::iterator UTI = UT.find(I->second);
- if (UTI == UT.end())
+
+ // If this isn't a struct type, remove it from our set of types to name.
+ // This simplifies emission later.
+ if (!isa<StructType>(I->second)) {
TST.remove(I);
- else
- UT.erase(UTI); // Only keep one name for this type.
+ } else {
+ // If this is not used, remove it from the symbol table.
+ std::set<const Type *>::iterator UTI = UT.find(I->second);
+ if (UTI == UT.end())
+ TST.remove(I);
+ else
+ UT.erase(UTI); // Only keep one name for this type.
+ }
}
// UT now contains types that are not named. Loop over it, naming
@@ -1694,10 +1700,11 @@
Out << '\n';
- // Now we can print out typedefs...
+ // Now we can print out typedefs. Above, we guaranteed that this can only be
+ // for struct types.
Out << "/* Typedefs */\n";
for (I = TST.begin(); I != End; ++I) {
- const Type *Ty = cast<Type>(I->second);
+ const StructType *Ty = cast<StructType>(I->second);
std::string Name = "l_" + Mang->makeNameProper(I->first);
Out << "typedef ";
printType(Out, Ty, false, Name);
More information about the llvm-commits
mailing list