Use set directive for StartMinusEndExpr.
authorDevang Patel <dpatel@apple.com>
Thu, 2 Dec 2010 21:32:30 +0000 (21:32 +0000)
committerDevang Patel <dpatel@apple.com>
Thu, 2 Dec 2010 21:32:30 +0000 (21:32 +0000)
This is a fix for llvm-gcc-i386-darwin9 buildbot failure.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120742 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCObjectStreamer.h
include/llvm/MC/MCStreamer.h
lib/MC/MCAsmStreamer.cpp
lib/MC/MCDwarf.cpp
lib/MC/MCLoggingStreamer.cpp
lib/MC/MCNullStreamer.cpp
lib/MC/MCObjectStreamer.cpp
lib/Target/PTX/PTXMCAsmStreamer.cpp
test/CodeGen/X86/2010-12-02-MC-Set.ll [new file with mode: 0644]

index c4f5e348b23a4e4a001ba8cf223942cbc36cb153..092bc84703908011802a1e7a673631b2ac5b531a 100644 (file)
@@ -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);
index 1424785444074cdef20a6eed2f51441f6ca6f82d..4c96b2fce52f54e00ead9915ca273f7e4ee8f8b3 100644 (file)
@@ -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.
index 02b666235e3792d970d70c187350d0639eff5d9c..30a3105bd798af0422fac636347312f41dd15350 100644 (file)
@@ -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();
 }
index adefa5d31003f6d96b76a8caf872f8d9646165eb..0daf2959e33cfbc71ddff3faf8eb742310af4761 100644 (file)
@@ -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);
index 38cb5c708c0a4925a5cd4a0d9e8cae561f9f35c1..5191ac4a72ca6751c2983606adc63c50ee6ac0a9 100644 (file)
@@ -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);
   }
index c781fe65622ceca69a918ea40b5c9fbc5e649f6b..c79793ceed19a459b73bf9baf40916815f8cf846 100644 (file)
@@ -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,
index 331f72688797331736424e56bf523f4ffa88050a..a514858545a127796d9c38b2ea5fdb312eacc7fb 100644 (file)
@@ -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();
 
index 864781119eeadb55d8e477538c193a71b6cbcd4b..0b49bcc43f6266b41bdec43ac8161cd7bb09ac63 100644 (file)
@@ -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 (file)
index 0000000..3144678
--- /dev/null
@@ -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