Use createTempSymbol to avoid collisions instead of an ad hoc method.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 17 Mar 2015 14:50:32 +0000 (14:50 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 17 Mar 2015 14:50:32 +0000 (14:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232483 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/PowerPC/PPCAsmPrinter.cpp
test/CodeGen/PowerPC/2012-09-16-TOC-entry-check.ll
test/CodeGen/PowerPC/alias.ll

index 02421a58be1d2f4841c23741734ee3bf32b284bd..e8bfd68ae4793564622dbb9b083bf265c091bd8c 100644 (file)
@@ -321,17 +321,9 @@ bool PPCAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
 /// exists for it.  If not, create one.  Then return a symbol that references
 /// the TOC entry.
 MCSymbol *PPCAsmPrinter::lookUpOrCreateTOCEntry(MCSymbol *Sym) {
-  const DataLayout *DL = TM.getDataLayout();
   MCSymbol *&TOCEntry = TOC[Sym];
-
-  // To avoid name clash check if the name already exists.
-  while (!TOCEntry) {
-    if (OutContext.LookupSymbol(Twine(DL->getPrivateGlobalPrefix()) +
-                                "C" + Twine(TOCLabelID++)) == nullptr) {
-      TOCEntry = GetTempSymbol("C", TOCLabelID);
-    }
-  }
-
+  if (!TOCEntry)
+    TOCEntry = createTempSymbol("C", TOCLabelID++);
   return TOCEntry;
 }
 
index 5bff58f2bbf55c53f7ba256d05b6f9be7ce5ba47..1d45c2e73455dbcdac94b4a94ee1ee9869754c0c 100644 (file)
@@ -19,9 +19,9 @@ define i32 @foo(double %X, double %Y) nounwind readnone {
 }
 
 ; Check the creation of 2 .tc entries for both double constants. They
-; should be .LC1 and .LC3 to avoid name clash with global constants
-; .LC0 and .LC2
-; CHECK: .LC{{[13]}}:
+; avoid name clash with global constants .LC0 and .LC2
+; CHECK: .section      .toc,"aw",@progbits
+; CHECK: .LC{{.*}}:
 ; CHECK-NEXT: .tc {{[\._a-zA-Z0-9]+}}[TC],{{[\._a-zA-Z0-9]+}}
-; CHECK: .LC{{[13]}}:
+; CHECK: .LC{{.*}}:
 ; CHECK-NEXT: .tc {{[\._a-zA-Z0-9]+}}[TC],{{[\._a-zA-Z0-9]+}}
index b1521d63b63217db8f1b81c40e010e3c77b411ee..524abd5da3efb62ae42e6bc438bf0cb5bc5489ff 100644 (file)
@@ -10,7 +10,7 @@
 ; CHECK-LABEL: bar:
 define i32 @bar() {
 ; MEDIUM: addis 3, 2, fooa@toc@ha
-; LARGE: addis 3, 2, .LC1@toc@ha
+; LARGE: addis 3, 2, .L[[L0:.*]]@toc@ha
   %a = load i32, i32* @fooa
   ret i32 %a
 }
@@ -19,13 +19,13 @@ define i32 @bar() {
 define i64 @bar2() {
 ; MEDIUM: addis 3, 2, foo2a@toc@ha
 ; MEDIUM: addi 3, 3, foo2a@toc@l
-; LARGE: addis 3, 2, .LC3@toc@ha
+; LARGE: addis 3, 2, .L[[L1:.*]]@toc@ha
   %a = load i64, i64* @foo2a
   ret i64 %a
 }
 
-; LARGE: .LC1:
+; LARGE: .L[[L0]]:
 ; LARGE-NEXT: .tc fooa[TC],fooa
 
-; LARGE: .LC3:
+; LARGE: .L[[L1]]:
 ; LARGE-NEXT: .tc foo2a[TC],foo2a