[llvm-commits] [llvm] r129210 - in /llvm/trunk: lib/MC/MCContext.cpp test/MC/AsmParser/rename.s
Benjamin Kramer
benny.kra at googlemail.com
Sat Apr 9 04:26:27 PDT 2011
Author: d0k
Date: Sat Apr 9 06:26:27 2011
New Revision: 129210
URL: http://llvm.org/viewvc/llvm-project?rev=129210&view=rev
Log:
Don't store Twine temporaries, it's not safe.
And don't append the name over and over again in the loop.
Modified:
llvm/trunk/lib/MC/MCContext.cpp
llvm/trunk/test/MC/AsmParser/rename.s
Modified: llvm/trunk/lib/MC/MCContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=129210&r1=129209&r2=129210&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCContext.cpp (original)
+++ llvm/trunk/lib/MC/MCContext.cpp Sat Apr 9 06:26:27 2011
@@ -85,12 +85,11 @@
StringMapEntry<bool> *NameEntry = &UsedNames.GetOrCreateValue(Name);
if (NameEntry->getValue()) {
assert(isTemporary && "Cannot rename non temporary symbols");
- SmallString<128> NewName;
+ SmallString<128> NewName = Name;
do {
- Twine T = Name + Twine(NextUniqueID++);
- T.toVector(NewName);
- StringRef foo = NewName;
- NameEntry = &UsedNames.GetOrCreateValue(foo);
+ NewName.resize(Name.size());
+ raw_svector_ostream(NewName) << NextUniqueID++;
+ NameEntry = &UsedNames.GetOrCreateValue(NewName);
} while (NameEntry->getValue());
}
NameEntry->setValue(true);
@@ -110,9 +109,8 @@
MCSymbol *MCContext::CreateTempSymbol() {
SmallString<128> NameSV;
- Twine Name = Twine(MAI.getPrivateGlobalPrefix()) + "tmp" +
- Twine(NextUniqueID++);
- Name.toVector(NameSV);
+ raw_svector_ostream(NameSV)
+ << MAI.getPrivateGlobalPrefix() << "tmp" << NextUniqueID++;
return CreateSymbol(NameSV);
}
Modified: llvm/trunk/test/MC/AsmParser/rename.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/rename.s?rev=129210&r1=129209&r2=129210&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/rename.s (original)
+++ llvm/trunk/test/MC/AsmParser/rename.s Sat Apr 9 06:26:27 2011
@@ -1,10 +1,14 @@
// RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
.size bar, . - bar
+.Ltmp01:
+ .size foo, .Ltmp01 - foo
.Ltmp0:
- .size foo, .Ltmp0 - foo
+ .size qux, .Ltmp0 - qux
// CHECK: .Ltmp0:
// CHECK: .size bar, .Ltmp0-bar
// CHECK: .Ltmp01
// CHECK: .size foo, .Ltmp01-foo
+// CHECK: .Ltmp02
+// CHECK: .size qux, .Ltmp02-qux
More information about the llvm-commits
mailing list