aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanjiv Gupta <sanjiv.gupta@microchip.com>2009-07-27 18:04:34 +0000
committerSanjiv Gupta <sanjiv.gupta@microchip.com>2009-07-27 18:04:34 +0000
commitbe7b97b773529cdf60da9868586c89271476c625 (patch)
tree5ee2716ff85dd455600d81dda4cf793deb5ef29a
parente34887d5d02e8bd42b414fb17f69c35b8d13695d (diff)
downloadexternal_llvm-be7b97b773529cdf60da9868586c89271476c625.zip
external_llvm-be7b97b773529cdf60da9868586c89271476c625.tar.gz
external_llvm-be7b97b773529cdf60da9868586c89271476c625.tar.bz2
Remove duplicate entries while printing decls for external symbols.
Some libcall names are same, so they were getting printed twice. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77215 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/PIC16/PIC16AsmPrinter.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/Target/PIC16/PIC16AsmPrinter.cpp b/lib/Target/PIC16/PIC16AsmPrinter.cpp
index 443ced0..ec86585 100644
--- a/lib/Target/PIC16/PIC16AsmPrinter.cpp
+++ b/lib/Target/PIC16/PIC16AsmPrinter.cpp
@@ -156,6 +156,26 @@ void PIC16AsmPrinter::printCCOperand(const MachineInstr *MI, int opNum) {
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 @@ void PIC16AsmPrinter::printLibcallDecls(void) {
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";