From 822facd787aec5cbb8ae470d4ec8d87b25143fcd Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Thu, 2 Dec 2010 21:32:30 +0000 Subject: [PATCH] Use set directive for StartMinusEndExpr. This is a fix for llvm-gcc-i386-darwin9 buildbot failure. llvm-svn: 120742 --- include/llvm/MC/MCObjectStreamer.h | 3 ++- include/llvm/MC/MCStreamer.h | 2 +- lib/MC/MCAsmStreamer.cpp | 13 +++++++++++-- lib/MC/MCDwarf.cpp | 4 ++-- lib/MC/MCLoggingStreamer.cpp | 3 ++- lib/MC/MCNullStreamer.cpp | 2 +- lib/MC/MCObjectStreamer.cpp | 2 +- lib/Target/PTX/PTXMCAsmStreamer.cpp | 5 +++-- test/CodeGen/X86/2010-12-02-MC-Set.ll | 22 ++++++++++++++++++++++ 9 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 test/CodeGen/X86/2010-12-02-MC-Set.ll diff --git a/include/llvm/MC/MCObjectStreamer.h b/include/llvm/MC/MCObjectStreamer.h index c4f5e348b23..092bc847039 100644 --- a/include/llvm/MC/MCObjectStreamer.h +++ b/include/llvm/MC/MCObjectStreamer.h @@ -60,7 +60,8 @@ public: /// @{ virtual void EmitLabel(MCSymbol *Symbol); - virtual void EmitValue(const MCExpr *Value, unsigned Size,unsigned AddrSpace); + virtual void EmitValue(const MCExpr *Value, unsigned Size,unsigned AddrSpace, + bool UseSet = false); virtual void EmitULEB128Value(const MCExpr *Value, unsigned AddrSpace = 0); virtual void EmitSLEB128Value(const MCExpr *Value, unsigned AddrSpace = 0); virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol); diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 14247854440..4c96b2fce52 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -242,7 +242,7 @@ namespace llvm { /// @param Size - The size of the integer (in bytes) to emit. This must /// match a native machine width. virtual void EmitValue(const MCExpr *Value, unsigned Size, - unsigned AddrSpace = 0) = 0; + unsigned AddrSpace = 0, bool UseSet = false) = 0; /// EmitIntValue - Special case of EmitValue that avoids the client having /// to pass in a MCExpr for constant integers. diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp index 02b666235e3..30a3105bd79 100644 --- a/lib/MC/MCAsmStreamer.cpp +++ b/lib/MC/MCAsmStreamer.cpp @@ -147,7 +147,8 @@ public: virtual void EmitBytes(StringRef Data, unsigned AddrSpace); - virtual void EmitValue(const MCExpr *Value, unsigned Size,unsigned AddrSpace); + virtual void EmitValue(const MCExpr *Value, unsigned Size,unsigned AddrSpace, + bool UseSet = false); virtual void EmitULEB128Value(const MCExpr *Value, unsigned AddrSpace = 0); @@ -495,7 +496,7 @@ void MCAsmStreamer::EmitBytes(StringRef Data, unsigned AddrSpace) { } void MCAsmStreamer::EmitValue(const MCExpr *Value, unsigned Size, - unsigned AddrSpace) { + unsigned AddrSpace, bool UseSet) { assert(CurSection && "Cannot emit contents before setting section!"); const char *Directive = 0; switch (Size) { @@ -521,6 +522,14 @@ void MCAsmStreamer::EmitValue(const MCExpr *Value, unsigned Size, } assert(Directive && "Invalid size for machine code value!"); + if (UseSet && MAI.hasSetDirective()) { + MCSymbol *SetLabel = getContext().CreateTempSymbol(); + EmitAssignment(SetLabel, Value); + OS << Directive << *SetLabel; + EmitEOL(); + return; + } + OS << Directive << *Value; EmitEOL(); } diff --git a/lib/MC/MCDwarf.cpp b/lib/MC/MCDwarf.cpp index adefa5d3100..0daf2959e33 100644 --- a/lib/MC/MCDwarf.cpp +++ b/lib/MC/MCDwarf.cpp @@ -256,7 +256,7 @@ void MCDwarfFileTable::Emit(MCStreamer *MCOS, // The first 4 bytes is the total length of the information for this // compilation unit (not including these 4 bytes for the length). MCOS->EmitValue(MakeStartMinusEndExpr(MCOS, LineStartSym, LineEndSym, 4), - 4, 0); + 4, 0, true /*UseSet*/); // Next 2 bytes is the Version, which is Dwarf 2. MCOS->EmitIntValue(2, 2); @@ -270,7 +270,7 @@ void MCDwarfFileTable::Emit(MCStreamer *MCOS, // length of the prologue. MCOS->EmitValue(MakeStartMinusEndExpr(MCOS, LineStartSym, ProEndSym, (4 + 2 + 4)), - 4, 0); + 4, 0, true /*UseSet*/); // Parameters of the state machine, are next. MCOS->EmitIntValue(DWARF2_LINE_MIN_INSN_LENGTH, 1); diff --git a/lib/MC/MCLoggingStreamer.cpp b/lib/MC/MCLoggingStreamer.cpp index 38cb5c708c0..5191ac4a72c 100644 --- a/lib/MC/MCLoggingStreamer.cpp +++ b/lib/MC/MCLoggingStreamer.cpp @@ -147,7 +147,8 @@ public: return Child->EmitBytes(Data, AddrSpace); } - virtual void EmitValue(const MCExpr *Value, unsigned Size,unsigned AddrSpace){ + virtual void EmitValue(const MCExpr *Value, unsigned Size,unsigned AddrSpace, + bool UseSet = false){ LogCall("EmitValue"); return Child->EmitValue(Value, Size, AddrSpace); } diff --git a/lib/MC/MCNullStreamer.cpp b/lib/MC/MCNullStreamer.cpp index c781fe65622..c79793ceed1 100644 --- a/lib/MC/MCNullStreamer.cpp +++ b/lib/MC/MCNullStreamer.cpp @@ -66,7 +66,7 @@ namespace { virtual void EmitBytes(StringRef Data, unsigned AddrSpace) {} virtual void EmitValue(const MCExpr *Value, unsigned Size, - unsigned AddrSpace) {} + unsigned AddrSpace, bool UseSet = false) {} virtual void EmitULEB128Value(const MCExpr *Value, unsigned AddrSpace = 0) {} virtual void EmitSLEB128Value(const MCExpr *Value, diff --git a/lib/MC/MCObjectStreamer.cpp b/lib/MC/MCObjectStreamer.cpp index 331f7268879..a514858545a 100644 --- a/lib/MC/MCObjectStreamer.cpp +++ b/lib/MC/MCObjectStreamer.cpp @@ -77,7 +77,7 @@ const MCExpr *MCObjectStreamer::AddValueSymbols(const MCExpr *Value) { } void MCObjectStreamer::EmitValue(const MCExpr *Value, unsigned Size, - unsigned AddrSpace) { + unsigned AddrSpace, bool UseSet) { assert(AddrSpace == 0 && "Address space must be 0!"); MCDataFragment *DF = getOrCreateDataFragment(); diff --git a/lib/Target/PTX/PTXMCAsmStreamer.cpp b/lib/Target/PTX/PTXMCAsmStreamer.cpp index 864781119ee..0b49bcc43f6 100644 --- a/lib/Target/PTX/PTXMCAsmStreamer.cpp +++ b/lib/Target/PTX/PTXMCAsmStreamer.cpp @@ -143,7 +143,8 @@ public: virtual void EmitBytes(StringRef Data, unsigned AddrSpace); - virtual void EmitValue(const MCExpr *Value, unsigned Size,unsigned AddrSpace); + virtual void EmitValue(const MCExpr *Value, unsigned Size,unsigned AddrSpace, + bool UseSet = false); virtual void EmitULEB128Value(const MCExpr *Value, unsigned AddrSpace = 0); virtual void EmitSLEB128Value(const MCExpr *Value, unsigned AddrSpace = 0); virtual void EmitGPRel32Value(const MCExpr *Value); @@ -350,7 +351,7 @@ void PTXMCAsmStreamer::EmitBytes(StringRef Data, unsigned AddrSpace) { } void PTXMCAsmStreamer::EmitValue(const MCExpr *Value, unsigned Size, - unsigned AddrSpace) { + unsigned AddrSpace, bool UseSet) { assert(CurSection && "Cannot emit contents before setting section!"); const char *Directive = 0; switch (Size) { diff --git a/test/CodeGen/X86/2010-12-02-MC-Set.ll b/test/CodeGen/X86/2010-12-02-MC-Set.ll new file mode 100644 index 00000000000..31446786ec1 --- /dev/null +++ b/test/CodeGen/X86/2010-12-02-MC-Set.ll @@ -0,0 +1,22 @@ +; RUN: llc < %s -disable-dot-loc -mtriple=x86_64-apple-darwin -O0 | FileCheck %s + + +define void @foo() nounwind ssp { +entry: + ret void, !dbg !5 +} + +!llvm.dbg.sp = !{!0} + +!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"foo", metadata !"foo", metadata !"", metadata !1, i32 3, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void ()* @foo} ; [ DW_TAG_subprogram ] +!1 = metadata !{i32 589865, metadata !"e.c", metadata !"/private/tmp", metadata !2} ; [ DW_TAG_file_type ] +!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"e.c", metadata !"/private/tmp", metadata !"clang version 2.9 (trunk 120563)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ] +!4 = metadata !{null} +!5 = metadata !{i32 5, i32 1, metadata !6, null} +!6 = metadata !{i32 589835, metadata !0, i32 3, i32 16, metadata !1, i32 0} ; [ DW_TAG_lexical_block ] + +; CHECK: .subsections_via_symbols +; CHECK-NEXT: __debug_line +; CHECK-NEXT: Ltmp +; CHECK-NEXT: Ltmp{{[0-9]}} = (Ltmp