[llvm-commits] [llvm] r151547 - in /llvm/trunk: lib/Target/PowerPC/PPCAsmPrinter.cpp test/CodeGen/PowerPC/ppc64-linux-func-size.ll

Roman Divacky rdivacky at freebsd.org
Mon Feb 27 12:20:47 PST 2012


Author: rdivacky
Date: Mon Feb 27 14:20:47 2012
New Revision: 151547

URL: http://llvm.org/viewvc/llvm-project?rev=151547&view=rev
Log:
Reapply r151278 with fixes.

MCize function entry label emission on PowerPC64 properly.


Modified:
    llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp
    llvm/trunk/test/CodeGen/PowerPC/ppc64-linux-func-size.ll

Modified: llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp?rev=151547&r1=151546&r2=151547&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp Mon Feb 27 14:20:47 2012
@@ -39,6 +39,7 @@
 #include "llvm/MC/MCSectionMachO.h"
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSymbol.h"
+#include "llvm/MC/MCSectionELF.h"
 #include "llvm/Target/Mangler.h"
 #include "llvm/Target/TargetRegisterInfo.h"
 #include "llvm/Target/TargetInstrInfo.h"
@@ -49,6 +50,7 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/ELF.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "InstPrinter/PPCInstPrinter.h"
@@ -391,13 +393,21 @@
     return AsmPrinter::EmitFunctionEntryLabel();
     
   // Emit an official procedure descriptor.
-  // FIXME 64-bit SVR4: Use MCSection here!
-  OutStreamer.EmitRawText(StringRef("\t.section\t\".opd\",\"aw\""));
-  OutStreamer.EmitRawText(StringRef("\t.align 3"));
+  const MCSection *Current = OutStreamer.getCurrentSection();
+  const MCSectionELF *Section = OutStreamer.getContext().getELFSection(".opd",
+      ELF::SHT_PROGBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC,
+      SectionKind::getReadOnly());
+  OutStreamer.SwitchSection(Section);
   OutStreamer.EmitLabel(CurrentFnSym);
-  OutStreamer.EmitRawText("\t.quad .L." + Twine(CurrentFnSym->getName()) +
-                          ",.TOC. at tocbase");
-  OutStreamer.EmitRawText(StringRef("\t.previous"));
+  OutStreamer.EmitValueToAlignment(8);
+  MCSymbol *Symbol1 = 
+    OutContext.GetOrCreateSymbol(".L." + Twine(CurrentFnSym->getName()));
+  MCSymbol *Symbol2 = OutContext.GetOrCreateSymbol(StringRef(".TOC. at tocbase"));
+  OutStreamer.EmitValue(MCSymbolRefExpr::Create(Symbol1, OutContext),
+                        Subtarget.isPPC64() ? 8 : 4/*size*/, 0/*addrspace*/);
+  OutStreamer.EmitValue(MCSymbolRefExpr::Create(Symbol2, OutContext),
+                        Subtarget.isPPC64() ? 8 : 4/*size*/, 0/*addrspace*/);
+  OutStreamer.SwitchSection(Current);
 
   MCSymbol *RealFnSym = OutContext.GetOrCreateSymbol(
                           ".L." + Twine(CurrentFnSym->getName()));

Modified: llvm/trunk/test/CodeGen/PowerPC/ppc64-linux-func-size.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/ppc64-linux-func-size.ll?rev=151547&r1=151546&r2=151547&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/ppc64-linux-func-size.ll (original)
+++ llvm/trunk/test/CodeGen/PowerPC/ppc64-linux-func-size.ll Mon Feb 27 14:20:47 2012
@@ -1,8 +1,10 @@
 ; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=g5 | FileCheck %s
 
 ; CHECK: test1:
-; CHECK-NEXT:  .quad .L.test1,.TOC. at tocbase
-; CHECK-NEXT:  .previous
+; CHECK-NEXT:	.align 3
+; CHECK-NEXT:	.quad .L.test1
+; CHECK-NEXT:	.quad .TOC. at tocbase
+; CHECK-NEXT:	.text
 ; CHECK-NEXT: .L.test1:
 
 define i32 @test1(i32 %a) nounwind {





More information about the llvm-commits mailing list