X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FIR%2FMangler.cpp;h=575141aed85bdf1f74d9283607a278375fd325bc;hb=2970677f21ef006e6c8477e0c3f58fdd28b2ac03;hp=5a099738d55a12f7ab104dc4ce830688b78aebc6;hpb=916d3120b30a0e77dde8368d4f44a97ed6bee53d;p=oota-llvm.git diff --git a/lib/IR/Mangler.cpp b/lib/IR/Mangler.cpp index 5a099738d55..575141aed85 100644 --- a/lib/IR/Mangler.cpp +++ b/lib/IR/Mangler.cpp @@ -27,6 +27,13 @@ static void getNameWithPrefixx(raw_ostream &OS, const Twine &GVName, StringRef Name = GVName.toStringRef(TmpData); assert(!Name.empty() && "getNameWithPrefix requires non-empty name"); + // No need to do anything special if the global has the special "do not + // mangle" flag in the name. + if (Name[0] == '\1') { + OS << Name.substr(1); + return; + } + if (PrefixTy == Mangler::Private) OS << DL.getPrivateGlobalPrefix(); else if (PrefixTy == Mangler::LinkerPrivate) @@ -44,13 +51,14 @@ static void getNameWithPrefixx(raw_ostream &OS, const Twine &GVName, OS << Name; } -void Mangler::getNameWithPrefix(raw_ostream &OS, - const Twine &GVName, ManglerPrefixTy PrefixTy) { +void Mangler::getNameWithPrefix(raw_ostream &OS, const Twine &GVName, + ManglerPrefixTy PrefixTy) const { return getNameWithPrefixx(OS, GVName, PrefixTy, *DL, false); } void Mangler::getNameWithPrefix(SmallVectorImpl &OutName, - const Twine &GVName, ManglerPrefixTy PrefixTy) { + const Twine &GVName, + ManglerPrefixTy PrefixTy) const { raw_svector_ostream OS(OutName); return getNameWithPrefix(OS, GVName, PrefixTy); } @@ -64,9 +72,12 @@ static void AddFastCallStdCallSuffix(raw_ostream &OS, const Function *F, unsigned ArgWords = 0; for (Function::const_arg_iterator AI = F->arg_begin(), AE = F->arg_end(); AI != AE; ++AI) { + // Skip arguments in registers to handle typical fastcall lowering. + if (F->getAttributes().hasAttribute(AI->getArgNo() + 1, Attribute::InReg)) + continue; Type *Ty = AI->getType(); - // 'Dereference' type in case of byval parameter attribute - if (AI->hasByValAttr()) + // 'Dereference' type in case of byval or inalloca parameter attribute. + if (AI->hasByValOrInAllocaAttr()) Ty = cast(Ty)->getElementType(); // Size should be aligned to DWORD boundary ArgWords += ((TD.getTypeAllocSize(Ty) + 3)/4)*4; @@ -75,12 +86,15 @@ static void AddFastCallStdCallSuffix(raw_ostream &OS, const Function *F, OS << '@' << ArgWords; } -void Mangler::getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV) { +void Mangler::getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, + bool CannotUsePrivateLabel) const { ManglerPrefixTy PrefixTy = Mangler::Default; - if (GV->hasPrivateLinkage()) - PrefixTy = Mangler::Private; - else if (GV->hasLinkerPrivateLinkage() || GV->hasLinkerPrivateWeakLinkage()) - PrefixTy = Mangler::LinkerPrivate; + if (GV->hasPrivateLinkage()) { + if (CannotUsePrivateLabel) + PrefixTy = Mangler::LinkerPrivate; + else + PrefixTy = Mangler::Private; + } if (!GV->hasName()) { // Get the ID for the global, assigning a new one if we haven't got one @@ -96,17 +110,10 @@ void Mangler::getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV) { StringRef Name = GV->getName(); - // No need to do anything special if the global has the special "do not - // mangle" flag in the name. - if (Name[0] == '\1') { - OS << Name.substr(1); - return; - } - bool UseAt = false; - const Function *MSFunc = NULL; + const Function *MSFunc = nullptr; CallingConv::ID CC; - if (DL->hasMicrosoftFastStdCallMangling()) { + if (Name[0] != '\1' && DL->hasMicrosoftFastStdCallMangling()) { if ((MSFunc = dyn_cast(GV))) { CC = MSFunc->getCallingConv(); // fastcall functions need to start with @ instead of _. @@ -133,7 +140,8 @@ void Mangler::getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV) { } void Mangler::getNameWithPrefix(SmallVectorImpl &OutName, - const GlobalValue *GV) { + const GlobalValue *GV, + bool CannotUsePrivateLabel) const { raw_svector_ostream OS(OutName); - getNameWithPrefix(OS, GV); + getNameWithPrefix(OS, GV, CannotUsePrivateLabel); }