[pr20127] Check for leading \1 in the Twine version of getNameWithPrefix.
authorRafael Espindola <rafael.espindola@gmail.com>
Fri, 1 Aug 2014 14:16:40 +0000 (14:16 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Fri, 1 Aug 2014 14:16:40 +0000 (14:16 +0000)
No functionality change, but will simplify an upcoming patch that uses the
Twine version.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214515 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/Mangler.cpp

index 27d973b94f0a2ac66927d47ce8f58797811cc306..bfed3e39f4edb8448001a3d538c79554ae75778b 100644 (file)
@@ -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)
@@ -100,17 +107,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 = nullptr;
   CallingConv::ID CC;
-  if (DL->hasMicrosoftFastStdCallMangling()) {
+  if (Name[0] != '\1' && DL->hasMicrosoftFastStdCallMangling()) {
     if ((MSFunc = dyn_cast<Function>(GV))) {
       CC = MSFunc->getCallingConv();
       // fastcall functions need to start with @ instead of _.