Avoid a call to getOrCreateSymbol when we already have the symbol.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238890 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2015-06-03 00:02:40 +00:00
parent 9c8ebbf969
commit 2bff0d30f8

View File

@ -128,6 +128,7 @@ GetSymbolFromOperand(const MachineOperand &MO) const {
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 MachineOperand &MO) const {
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);