[llvm-commits] [llvm] r77215 - /llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp

Chris Lattner clattner at apple.com
Mon Jul 27 11:40:15 PDT 2009


On Jul 27, 2009, at 11:04 AM, Sanjiv Gupta wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=77215&view=rev
> Log:
> Remove duplicate entries while printing decls for external symbols.
> Some libcall names are same, so they were getting printed twice.

Sanjiv, these are both really expensive.  They create temporary string  
objects.  Why not just use strcmp?

-Chris

>
> Modified:
>    llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp
>
> Modified: llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp?rev=77215&r1=77214&r2=77215&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp (original)
> +++ llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp Mon Jul 27  
> 13:04:34 2009
> @@ -156,6 +156,26 @@
>   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) {
> +  std::string str1 = s1;
> +  std::string str2 = s2;
> +  int i = str1.compare(str2);
> +  // Return true if s1 is smaller or equal.
> +  if (i <= 0) return true;
> +  // false if s1 should come after s2.
> +  return false;
> +}
> +
> +// 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) {
> +  std::string str1 = s1;
> +  std::string str2 = s2;
> +  return str1 == str2;
> +}
> +
> /// printLibcallDecls - print the extern declarations for compiler
> /// intrinsics.
> ///
> @@ -165,8 +185,9 @@
>
>   O << TAI->getCommentString() << "External decls for libcalls -  
> BEGIN." <<"\n";
>   // Remove duplicate entries.
> -  LibcallDecls.sort();
> -  LibcallDecls.unique();
> +  LibcallDecls.sort(is_before);
> +  LibcallDecls.unique(is_duplicate);
> +
>   for (std::list<const char*>::const_iterator I =  
> LibcallDecls.begin();
>        I != LibcallDecls.end(); I++) {
>     O << TAI->getExternDirective() << *I << "\n";
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list