MCize function entry label emission on PowerPC64 properly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151278 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Roman Divacky 2012-02-23 20:28:39 +00:00
parent b6bd8ccd02
commit ca0af3a971
2 changed files with 17 additions and 8 deletions

View File

@ -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,19 @@ void PPCLinuxAsmPrinter::EmitFunctionEntryLabel() {
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, 0, SectionKind::getReadOnly());
OutStreamer.SwitchSection(Section);
OutStreamer.EmitLabel(CurrentFnSym);
OutStreamer.EmitRawText("\t.quad .L." + Twine(CurrentFnSym->getName()) +
",.TOC.@tocbase");
OutStreamer.EmitRawText(StringRef("\t.previous"));
MCSymbol *Symbol1 =
OutContext.GetOrCreateSymbol(".L." + Twine(CurrentFnSym->getName()));
MCSymbol *Symbol2 = OutContext.GetOrCreateSymbol(StringRef(".TOC.@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()));

View File

@ -1,8 +1,9 @@
; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=g5 | FileCheck %s
; CHECK: test1:
; CHECK-NEXT: .quad .L.test1,.TOC.@tocbase
; CHECK-NEXT: .previous
; CHECK-NEXT: .quad .L.test1
; CHECK-NEXT: .quad .TOC.@tocbase
; CHECK-NEXT: .text
; CHECK-NEXT: .L.test1:
define i32 @test1(i32 %a) nounwind {