[llvm-commits] [llvm] r99061 - in /llvm/trunk/lib/Target/PIC16/AsmPrinter: PIC16AsmPrinter.cpp PIC16AsmPrinter.h

Benjamin Kramer benny.kra at googlemail.com
Sat Mar 20 10:41:18 PDT 2010


Author: d0k
Date: Sat Mar 20 12:41:18 2010
New Revision: 99061

URL: http://llvm.org/viewvc/llvm-project?rev=99061&view=rev
Log:
PIC16: Simplify code by using a std::set<std::string> instead of a sorted & uniqued std::list of leaked char*.

Modified:
    llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp
    llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h

Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp?rev=99061&r1=99060&r2=99061&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.cpp Sat Mar 20 12:41:18 2010
@@ -184,7 +184,7 @@
       // by any chance, as we do not link in those as .bc lib. So these calls
       // are always external and it is safe to emit an extern.
       if (PAN::isMemIntrinsic(Sym->getName()))
-        LibcallDecls.push_back(createESName(Sym->getName()));
+        LibcallDecls.insert(Sym->getName());
 
       O << *Sym;
       break;
@@ -199,7 +199,7 @@
           Printname = PAN::Rename(Sname);
         }
         // Record these decls, we need to print them in asm as extern.
-        LibcallDecls.push_back(createESName(Printname));
+        LibcallDecls.insert(Printname);
       }
 
       O << Printname;
@@ -221,18 +221,6 @@
   O << PIC16CondCodeToString((PIC16CC::CondCodes)CC);
 }
 
-// This function is used to sort the decls list.
-// should return true if s1 should come before s2.
-static bool is_before(const char *s1, const char *s2) {
-  return strcmp(s1, s2) <= 0;
-}
-
-// This is used by list::unique below. 
-// unique will filter out duplicates if it knows them.
-static bool is_duplicate(const char *s1, const char *s2) {
-  return !strcmp(s1, s2);
-}
-
 /// printLibcallDecls - print the extern declarations for compiler 
 /// intrinsics.
 ///
@@ -241,12 +229,9 @@
   if (LibcallDecls.empty()) return;
 
   O << MAI->getCommentString() << "External decls for libcalls - BEGIN." <<"\n";
-  // Remove duplicate entries.
-  LibcallDecls.sort(is_before);
-  LibcallDecls.unique(is_duplicate);
 
-  for (std::list<const char*>::const_iterator I = LibcallDecls.begin(); 
-       I != LibcallDecls.end(); I++) {
+  for (std::set<std::string>::const_iterator I = LibcallDecls.begin(),
+       E = LibcallDecls.end(); I != E; I++) {
     O << MAI->getExternDirective() << *I << "\n";
   }
   O << MAI->getCommentString() << "External decls for libcalls - END." <<"\n";

Modified: llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h?rev=99061&r1=99060&r2=99061&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h (original)
+++ llvm/trunk/lib/Target/PIC16/AsmPrinter/PIC16AsmPrinter.h Sat Mar 20 12:41:18 2010
@@ -25,6 +25,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Target/TargetMachine.h"
 #include <list>
+#include <set>
 #include <string>
 
 namespace llvm {
@@ -80,7 +81,7 @@
     PIC16TargetLowering *PTLI;
     PIC16DbgInfo DbgInfo;
     const PIC16MCAsmInfo *PMAI;
-    std::list<const char *> LibcallDecls; // List of extern decls.
+    std::set<std::string> LibcallDecls; // Sorted & uniqued set of extern decls.
     std::vector<const GlobalVariable *> ExternalVarDecls;
     std::vector<const GlobalVariable *> ExternalVarDefs;
   };





More information about the llvm-commits mailing list