[llvm] r238890 - Avoid a call to getOrCreateSymbol when we already have the symbol.

Rafael Espindola rafael.espindola at gmail.com
Tue Jun 2 17:02:41 PDT 2015


Author: rafael
Date: Tue Jun  2 19:02:40 2015
New Revision: 238890

URL: http://llvm.org/viewvc/llvm-project?rev=238890&view=rev
Log:
Avoid a call to getOrCreateSymbol when we already have the symbol.

Modified:
    llvm/trunk/lib/Target/X86/X86MCInstLower.cpp

Modified: llvm/trunk/lib/Target/X86/X86MCInstLower.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCInstLower.cpp?rev=238890&r1=238889&r2=238890&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86MCInstLower.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86MCInstLower.cpp Tue Jun  2 19:02:40 2015
@@ -128,6 +128,7 @@ GetSymbolFromOperand(const MachineOperan
   const DataLayout *DL = TM.getDataLayout();
   assert((MO.isGlobal() || MO.isSymbol() || MO.isMBB()) && "Isn't a symbol reference");
 
+  MCSymbol *Sym = nullptr;
   SmallString<128> Name;
   StringRef Suffix;
 
@@ -160,12 +161,14 @@ GetSymbolFromOperand(const MachineOperan
     else
       getMang()->getNameWithPrefix(Name, MO.getSymbolName());
   } else if (MO.isMBB()) {
-    Name += MO.getMBB()->getSymbol()->getName();
+    assert(Suffix.empty());
+    Sym = MO.getMBB()->getSymbol();
   }
   unsigned OrigLen = Name.size() - PrefixLen;
 
   Name += Suffix;
-  MCSymbol *Sym = Ctx.getOrCreateSymbol(Name);
+  if (!Sym)
+    Sym = Ctx.getOrCreateSymbol(Name);
 
   StringRef OrigName = StringRef(Name).substr(PrefixLen, OrigLen);
 





More information about the llvm-commits mailing list