[llvm-commits] [llvm] r77578 - in /llvm/trunk/lib/Target/PIC16: PIC16.h PIC16AsmPrinter.cpp
Sanjiv Gupta
sanjiv.gupta at microchip.com
Wed Jul 29 21:15:18 PDT 2009
Author: sgupta
Date: Wed Jul 29 23:15:15 2009
New Revision: 77578
URL: http://llvm.org/viewvc/llvm-project?rev=77578&view=rev
Log:
Keep track of references to mem(cpy,move,set) and then print only one extern
declaration for them.
Modified:
llvm/trunk/lib/Target/PIC16/PIC16.h
llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp
Modified: llvm/trunk/lib/Target/PIC16/PIC16.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16.h?rev=77578&r1=77577&r2=77578&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16.h (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16.h Wed Jul 29 23:15:15 2009
@@ -255,6 +255,20 @@
return false;
}
+ // FIXME: currently we track both @memcpy and memcpy, as
+ // the first one is generated by clang, and the second one by codegen
+ // while lowering intrinsics. One we fix codegen to use RTLIB, we can
+ // have only @memcpy here.
+ inline static bool isMemIntrinsic (const std::string &Name) {
+ if (Name.compare("@memcpy") == 0 || Name.compare("memcpy") == 0 ||
+ Name.compare("@memset") == 0 || Name.compare("memset") == 0 ||
+ Name.compare("@memmove") == 0 || Name.compare("memmove") == 0) {
+ return true;
+ }
+
+ return false;
+ }
+
inline static bool isLocalToFunc (std::string &Func, std::string &Var) {
if (! isLocalName(Var)) return false;
Modified: llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp?rev=77578&r1=77577&r2=77578&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16AsmPrinter.cpp Wed Jul 29 23:15:15 2009
@@ -137,7 +137,15 @@
return;
case MachineOperand::MO_GlobalAddress: {
- O << Mang->getMangledName(MO.getGlobal());
+ std::string Sname = Mang->getMangledName(MO.getGlobal());
+ // FIXME: currently we do not have a memcpy def coming in the module
+ // 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(Sname)) {
+ LibcallDecls.push_back(createESName(Sname));
+ }
+
+ O << Sname;
break;
}
case MachineOperand::MO_ExternalSymbol: {
@@ -148,7 +156,14 @@
LibcallDecls.push_back(Sname);
}
- O << Sname;
+ // Record a call to intrinsic to print the extern declaration for it.
+ std::string Sym = Sname;
+ if (PAN::isMemIntrinsic(Sym)) {
+ Sym = PAN::addPrefix(Sym);
+ LibcallDecls.push_back(createESName(Sym));
+ }
+
+ O << Sym;
break;
}
case MachineOperand::MO_MachineBasicBlock:
@@ -253,6 +268,16 @@
if (!I->isDeclaration() && !I->hasExternalLinkage())
continue;
+ // Do not emit memcpy, memset, and memmove here.
+ // Calls to these routines can be generated in two ways,
+ // 1. User calling the standard lib function
+ // 2. Codegen generating these calls for llvm intrinsics.
+ // In the first case a prototype is alread availale, while in
+ // second case the call is via and externalsym and the prototype is missing.
+ // So declarations for these are currently always getting printing by
+ // tracking both kind of references in printInstrunction.
+ if (I->isDeclaration() && PAN::isMemIntrinsic(Name)) continue;
+
const char *directive = I->isDeclaration() ? TAI->getExternDirective() :
TAI->getGlobalDirective();
More information about the llvm-commits
mailing list