[LLVMdev] x86_stdcallcc @<n> mangling vs. '\1' prefix [was: x86_stdcallcc and extra name mangling on Windows]

David Nadlinger code at klickverbot.at
Wed Feb 20 12:29:29 PST 2013


On Wed, Feb 20, 2013 at 8:25 PM, Timur Iskhodzhanov <timurrrr at google.com> wrote:
> I don't remember anything other that what I've written in the bug João
> has mentioned.
>
> Probably something like this patch
> http://llvm.org/bugs/show_bug.cgi?id=14410#c6
> ?

My problem is not related to correctly implementing the MS
stdcall/fastcall ABI itself, but rather a (sufficiently) similar one.
Thus, I need to specifically disable mangling in a case where it would
normally be needed.

For the quick-and-dirty patch I'm currently using locally, see below.

David


diff --git a/lib/Target/Mangler.cpp b/lib/Target/Mangler.cpp
index edfd421..e4b6368 100644
--- a/lib/Target/Mangler.cpp
+++ b/lib/Target/Mangler.cpp
@@ -185,9 +185,12 @@ void
Mangler::getNameWithPrefix(SmallVectorImpl<char> &OutName,
     PrefixTy = Mangler::Private;
   else if (GV->hasLinkerPrivateLinkage() || GV->hasLinkerPrivateWeakLinkage())
     PrefixTy = Mangler::LinkerPrivate;
-
+
+  bool skipMangling = false;
+
   // If this global has a name, handle it simply.
   if (GV->hasName()) {
+    skipMangling = (GV->getName()[0] == '\1');
     getNameWithPrefix(OutName, GV->getName(), PrefixTy);
   } else {
     // Get the ID for the global, assigning a new one if we haven't got one
@@ -201,7 +204,7 @@ void
Mangler::getNameWithPrefix(SmallVectorImpl<char> &OutName,

   // If we are supposed to add a microsoft-style suffix for stdcall/fastcall,
   // add it.
-  if (Context.getAsmInfo().hasMicrosoftFastStdCallMangling()) {
+  if (!skipMangling &&
Context.getAsmInfo().hasMicrosoftFastStdCallMangling()) {
     if (const Function *F = dyn_cast<Function>(GV)) {
       CallingConv::ID CC = F->getCallingConv();




More information about the llvm-dev mailing list