[llvm] r214515 - [pr20127] Check for leading \1 in the Twine version of getNameWithPrefix.

Rafael Espindola rafael.espindola at gmail.com
Fri Aug 1 07:16:40 PDT 2014


Author: rafael
Date: Fri Aug  1 09:16:40 2014
New Revision: 214515

URL: http://llvm.org/viewvc/llvm-project?rev=214515&view=rev
Log:
[pr20127] Check for leading \1 in the Twine version of getNameWithPrefix.

No functionality change, but will simplify an upcoming patch that uses the
Twine version.

Modified:
    llvm/trunk/lib/IR/Mangler.cpp

Modified: llvm/trunk/lib/IR/Mangler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Mangler.cpp?rev=214515&r1=214514&r2=214515&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Mangler.cpp (original)
+++ llvm/trunk/lib/IR/Mangler.cpp Fri Aug  1 09:16:40 2014
@@ -27,6 +27,13 @@ static void getNameWithPrefixx(raw_ostre
   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_ostr
 
   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 _.





More information about the llvm-commits mailing list