summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-03-05 20:09:15 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-03-05 20:09:15 +0000
commitfc5436c95132cbbf3c2fc950d3c5906cc8ed62dd (patch)
tree9555e07e32414c6e43d3213e2256b1c700a1a441
parent82d372e12bc20de0a37c23a9a1f288f4fda0dae2 (diff)
downloadllvm-fc5436c95132cbbf3c2fc950d3c5906cc8ed62dd.tar.gz
llvm-fc5436c95132cbbf3c2fc950d3c5906cc8ed62dd.tar.bz2
llvm-fc5436c95132cbbf3c2fc950d3c5906cc8ed62dd.tar.xz
Always print the implicit .text at the start of an asm file.
Before llvm-mc would print it, but llc was assuming that it would produce another section changing directive before one was needed. That assumption is false with inline asm. Fixes PR19049. Another option would be to always create the section, but in the asm printer avoid printing sections changes during initialization. That would work, but * We do use the fact that llvm-mc prints it in testing. The tests can be changed if needed. * A quick poll on IRC suggest that most developers prefer the implicit .text to be printed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203001 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/MC/MCELFStreamer.h2
-rw-r--r--include/llvm/MC/MCStreamer.h5
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinter.cpp2
-rw-r--r--lib/MC/MCAsmStreamer.cpp5
-rw-r--r--lib/MC/MCELFStreamer.cpp2
-rw-r--r--lib/MC/MCStreamer.cpp2
-rw-r--r--lib/MC/WinCOFFStreamer.cpp4
-rw-r--r--test/CodeGen/X86/GC/ocaml-gc.ll6
-rw-r--r--test/CodeGen/X86/pr19049.ll7
9 files changed, 18 insertions, 17 deletions
diff --git a/include/llvm/MC/MCELFStreamer.h b/include/llvm/MC/MCELFStreamer.h
index 46b32d0de6..ad25e2ce7d 100644
--- a/include/llvm/MC/MCELFStreamer.h
+++ b/include/llvm/MC/MCELFStreamer.h
@@ -44,7 +44,7 @@ public:
/// @name MCStreamer Interface
/// @{
- virtual void InitSections(bool Force);
+ virtual void InitSections();
virtual void ChangeSection(const MCSection *Section,
const MCExpr *Subsection);
virtual void EmitLabel(MCSymbol *Symbol);
diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h
index 43fa42ba81..e9f6196063 100644
--- a/include/llvm/MC/MCStreamer.h
+++ b/include/llvm/MC/MCStreamer.h
@@ -352,10 +352,7 @@ public:
}
/// Create the default sections and set the initial one.
- ///
- /// @param Force - If false, a text streamer implementation can be a nop.
- /// Used by CodeGen to avoid starting every file with '.text'.
- virtual void InitSections(bool Force = true);
+ virtual void InitSections();
/// AssignSection - Sets the symbol's section.
///
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 4d35e86310..fb1d42c06f 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -175,7 +175,7 @@ bool AsmPrinter::doInitialization(Module &M) {
const_cast<TargetLoweringObjectFile&>(getObjFileLowering())
.Initialize(OutContext, TM);
- OutStreamer.InitSections(false);
+ OutStreamer.InitSections();
Mang = new Mangler(TM.getDataLayout());
diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp
index 31f5de56d7..8f0a702fb1 100644
--- a/lib/MC/MCAsmStreamer.cpp
+++ b/lib/MC/MCAsmStreamer.cpp
@@ -127,11 +127,6 @@ public:
virtual void ChangeSection(const MCSection *Section,
const MCExpr *Subsection);
- virtual void InitSections(bool Force) {
- if (Force)
- SwitchSection(getContext().getObjectFileInfo()->getTextSection());
- }
-
virtual void EmitLabel(MCSymbol *Symbol);
virtual void EmitDebugLabel(MCSymbol *Symbol);
diff --git a/lib/MC/MCELFStreamer.cpp b/lib/MC/MCELFStreamer.cpp
index 9ff9665d52..5f6a889769 100644
--- a/lib/MC/MCELFStreamer.cpp
+++ b/lib/MC/MCELFStreamer.cpp
@@ -38,7 +38,7 @@ using namespace llvm;
MCELFStreamer::~MCELFStreamer() {
}
-void MCELFStreamer::InitSections(bool Force) {
+void MCELFStreamer::InitSections() {
// This emulates the same behavior of GNU as. This makes it easier
// to compare the output as the major sections are in the same order.
SwitchSection(getContext().getObjectFileInfo()->getTextSection());
diff --git a/lib/MC/MCStreamer.cpp b/lib/MC/MCStreamer.cpp
index 02065daf24..0837389581 100644
--- a/lib/MC/MCStreamer.cpp
+++ b/lib/MC/MCStreamer.cpp
@@ -205,7 +205,7 @@ void MCStreamer::EmitEHSymAttributes(const MCSymbol *Symbol,
MCSymbol *EHSymbol) {
}
-void MCStreamer::InitSections(bool Force) {
+void MCStreamer::InitSections() {
SwitchSection(getContext().getObjectFileInfo()->getTextSection());
}
diff --git a/lib/MC/WinCOFFStreamer.cpp b/lib/MC/WinCOFFStreamer.cpp
index 445d26106a..55ae2fe23b 100644
--- a/lib/MC/WinCOFFStreamer.cpp
+++ b/lib/MC/WinCOFFStreamer.cpp
@@ -50,7 +50,7 @@ public:
// MCStreamer interface
- virtual void InitSections(bool Force);
+ virtual void InitSections();
virtual void EmitLabel(MCSymbol *Symbol);
virtual void EmitDebugLabel(MCSymbol *Symbol);
virtual void EmitAssemblerFlag(MCAssemblerFlag Flag);
@@ -123,7 +123,7 @@ void WinCOFFStreamer::AddCommonSymbol(MCSymbol *Symbol, uint64_t Size,
// MCStreamer interface
-void WinCOFFStreamer::InitSections(bool Force) {
+void WinCOFFStreamer::InitSections() {
// FIXME: this is identical to the ELF one.
// This emulates the same behavior of GNU as. This makes it easier
// to compare the output as the major sections are in the same order.
diff --git a/test/CodeGen/X86/GC/ocaml-gc.ll b/test/CodeGen/X86/GC/ocaml-gc.ll
index 6d5f8aebe1..37ddaf90bf 100644
--- a/test/CodeGen/X86/GC/ocaml-gc.ll
+++ b/test/CodeGen/X86/GC/ocaml-gc.ll
@@ -1,8 +1,10 @@
; RUN: llc < %s -mtriple=x86_64-linux-gnu | FileCheck %s
-define i32 @main(i32 %x) nounwind gc "ocaml" {
; CHECK: .text
-; CHECK-NEXT: .globl "caml<stdin>__code_begin"
+; CHECK-NEXT: .file "<stdin>"
+
+define i32 @main(i32 %x) nounwind gc "ocaml" {
+; CHECK: .globl "caml<stdin>__code_begin"
; CHECK-NEXT: "caml<stdin>__code_begin":
; CHECK-NEXT: .data
; CHECK-NEXT: .globl "caml<stdin>__data_begin"
diff --git a/test/CodeGen/X86/pr19049.ll b/test/CodeGen/X86/pr19049.ll
new file mode 100644
index 0000000000..027c9815e0
--- /dev/null
+++ b/test/CodeGen/X86/pr19049.ll
@@ -0,0 +1,7 @@
+; RUN: llc -mtriple x86_64-pc-linux %s -o - | FileCheck %s
+
+module asm ".pushsection foo"
+module asm ".popsection"
+
+; CHECK: .section foo,"",@progbits
+; CHECK: .text