From 0f2b10eb0d59c1b02aa63602756abb74f25877ae Mon Sep 17 00:00:00 2001 From: Reed Kotler Date: Fri, 3 May 2013 23:17:24 +0000 Subject: [PATCH] Remove some uneeded pseudos in the presence of the naked function attribute. llvm-svn: 181072 --- llvm/lib/Target/Mips/MipsAsmPrinter.cpp | 10 +++++++-- llvm/test/CodeGen/Mips/tnaked.ll | 29 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 llvm/test/CodeGen/Mips/tnaked.ll diff --git a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp index f4f71cbccb2f..6e4feda4f531 100644 --- a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp +++ b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp @@ -249,12 +249,18 @@ void MipsAsmPrinter::EmitFunctionEntryLabel() { void MipsAsmPrinter::EmitFunctionBodyStart() { MCInstLowering.Initialize(Mang, &MF->getContext()); - emitFrameDirective(); + bool IsNakedFunction = + MF->getFunction()-> + getAttributes().hasAttribute(AttributeSet::FunctionIndex, + Attribute::Naked); + if (!IsNakedFunction) + emitFrameDirective(); if (OutStreamer.hasRawTextSupport()) { SmallString<128> Str; raw_svector_ostream OS(Str); - printSavedRegsBitmask(OS); + if (!IsNakedFunction) + printSavedRegsBitmask(OS); OutStreamer.EmitRawText(OS.str()); if (!Subtarget->inMips16Mode()) { OutStreamer.EmitRawText(StringRef("\t.set\tnoreorder")); diff --git a/llvm/test/CodeGen/Mips/tnaked.ll b/llvm/test/CodeGen/Mips/tnaked.ll new file mode 100644 index 000000000000..f5bdd915b28c --- /dev/null +++ b/llvm/test/CodeGen/Mips/tnaked.ll @@ -0,0 +1,29 @@ +; RUN: llc -march=mipsel < %s | FileCheck %s + + +define void @tnaked() #0 { +entry: + ret void +} + +; CHECK: .ent tnaked +; CHECK: tnaked: +; CHECK-NOT: .frame {{.*}} +; CHECK-NOT: .mask {{.*}} +; CHECK-NOT: .fmask {{.*}} +; CHECK-NOT: addiu $sp, $sp, -8 + +define void @tnonaked() #1 { +entry: + ret void +} + +; CHECK: .ent tnonaked +; CHECK: tnonaked: +; CHECK: .frame $fp,8,$ra +; CHECK: .mask 0x40000000,-4 +; CHECK: .fmask 0x00000000,0 +; CHECK: addiu $sp, $sp, -8 + +attributes #0 = { naked noinline nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }